Spaces:
				
			
			
	
			
			
					
		Running
		
			on 
			
			CPU Upgrade
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
			on 
			
			CPU Upgrade
	Commit 
							
							·
						
						d392fbe
	
1
								Parent(s):
							
							c73ba9b
								
Remove unused files and configurations, including .gitignore, Makefile, requirements.txt, and various source files.
Browse files- .gitattributes +1 -1
 - .gitignore +0 -13
 - .pre-commit-config.yaml +0 -53
 - Makefile +0 -13
 - README.md +5 -36
 - app.py +655 -191
 - pyproject.toml +0 -13
 - requirements.txt +0 -16
 - src/about.py +0 -72
 - src/display/css_html_js.py +0 -105
 - src/display/formatting.py +0 -27
 - src/display/utils.py +0 -110
 - src/envs.py +0 -25
 - src/leaderboard/read_evals.py +0 -196
 - src/populate.py +0 -58
 - src/submission/check_validity.py +0 -99
 - src/submission/submit.py +0 -119
 
    	
        .gitattributes
    CHANGED
    
    | 
         @@ -25,6 +25,7 @@ 
     | 
|
| 25 | 
         
             
            *.safetensors filter=lfs diff=lfs merge=lfs -text
         
     | 
| 26 | 
         
             
            saved_model/**/* filter=lfs diff=lfs merge=lfs -text
         
     | 
| 27 | 
         
             
            *.tar.* filter=lfs diff=lfs merge=lfs -text
         
     | 
| 
         | 
|
| 28 | 
         
             
            *.tflite filter=lfs diff=lfs merge=lfs -text
         
     | 
| 29 | 
         
             
            *.tgz filter=lfs diff=lfs merge=lfs -text
         
     | 
| 30 | 
         
             
            *.wasm filter=lfs diff=lfs merge=lfs -text
         
     | 
| 
         @@ -32,4 +33,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text 
     | 
|
| 32 | 
         
             
            *.zip filter=lfs diff=lfs merge=lfs -text
         
     | 
| 33 | 
         
             
            *.zst filter=lfs diff=lfs merge=lfs -text
         
     | 
| 34 | 
         
             
            *tfevents* filter=lfs diff=lfs merge=lfs -text
         
     | 
| 35 | 
         
            -
            scale-hf-logo.png filter=lfs diff=lfs merge=lfs -text
         
     | 
| 
         | 
|
| 25 | 
         
             
            *.safetensors filter=lfs diff=lfs merge=lfs -text
         
     | 
| 26 | 
         
             
            saved_model/**/* filter=lfs diff=lfs merge=lfs -text
         
     | 
| 27 | 
         
             
            *.tar.* filter=lfs diff=lfs merge=lfs -text
         
     | 
| 28 | 
         
            +
            *.tar filter=lfs diff=lfs merge=lfs -text
         
     | 
| 29 | 
         
             
            *.tflite filter=lfs diff=lfs merge=lfs -text
         
     | 
| 30 | 
         
             
            *.tgz filter=lfs diff=lfs merge=lfs -text
         
     | 
| 31 | 
         
             
            *.wasm filter=lfs diff=lfs merge=lfs -text
         
     | 
| 
         | 
|
| 33 | 
         
             
            *.zip filter=lfs diff=lfs merge=lfs -text
         
     | 
| 34 | 
         
             
            *.zst filter=lfs diff=lfs merge=lfs -text
         
     | 
| 35 | 
         
             
            *tfevents* filter=lfs diff=lfs merge=lfs -text
         
     | 
| 
         | 
    	
        .gitignore
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            auto_evals/
         
     | 
| 2 | 
         
            -
            venv/
         
     | 
| 3 | 
         
            -
            __pycache__/
         
     | 
| 4 | 
         
            -
            .env
         
     | 
| 5 | 
         
            -
            .ipynb_checkpoints
         
     | 
| 6 | 
         
            -
            *ipynb
         
     | 
| 7 | 
         
            -
            .vscode/
         
     | 
| 8 | 
         
            -
             
     | 
| 9 | 
         
            -
            eval-queue/
         
     | 
| 10 | 
         
            -
            eval-results/
         
     | 
| 11 | 
         
            -
            eval-queue-bk/
         
     | 
| 12 | 
         
            -
            eval-results-bk/
         
     | 
| 13 | 
         
            -
            logs/
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        .pre-commit-config.yaml
    DELETED
    
    | 
         @@ -1,53 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            # Copyright (c) 2022, NVIDIA CORPORATION.  All rights reserved.
         
     | 
| 2 | 
         
            -
            #
         
     | 
| 3 | 
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 4 | 
         
            -
            # you may not use this file except in compliance with the License.
         
     | 
| 5 | 
         
            -
            # You may obtain a copy of the License at
         
     | 
| 6 | 
         
            -
            #
         
     | 
| 7 | 
         
            -
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 8 | 
         
            -
            #
         
     | 
| 9 | 
         
            -
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 10 | 
         
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 11 | 
         
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 12 | 
         
            -
            # See the License for the specific language governing permissions and
         
     | 
| 13 | 
         
            -
            # limitations under the License.
         
     | 
| 14 | 
         
            -
             
     | 
| 15 | 
         
            -
            default_language_version:
         
     | 
| 16 | 
         
            -
              python: python3
         
     | 
| 17 | 
         
            -
             
     | 
| 18 | 
         
            -
            ci:
         
     | 
| 19 | 
         
            -
              autofix_prs: true
         
     | 
| 20 | 
         
            -
              autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
         
     | 
| 21 | 
         
            -
              autoupdate_schedule: quarterly
         
     | 
| 22 | 
         
            -
             
     | 
| 23 | 
         
            -
            repos:
         
     | 
| 24 | 
         
            -
              - repo: https://github.com/pre-commit/pre-commit-hooks
         
     | 
| 25 | 
         
            -
                rev: v4.3.0
         
     | 
| 26 | 
         
            -
                hooks:
         
     | 
| 27 | 
         
            -
                  - id: check-yaml
         
     | 
| 28 | 
         
            -
                  - id: check-case-conflict
         
     | 
| 29 | 
         
            -
                  - id: detect-private-key
         
     | 
| 30 | 
         
            -
                  - id: check-added-large-files
         
     | 
| 31 | 
         
            -
                    args: ['--maxkb=1000']
         
     | 
| 32 | 
         
            -
                  - id: requirements-txt-fixer
         
     | 
| 33 | 
         
            -
                  - id: end-of-file-fixer
         
     | 
| 34 | 
         
            -
                  - id: trailing-whitespace
         
     | 
| 35 | 
         
            -
             
     | 
| 36 | 
         
            -
              - repo: https://github.com/PyCQA/isort
         
     | 
| 37 | 
         
            -
                rev: 5.12.0
         
     | 
| 38 | 
         
            -
                hooks:
         
     | 
| 39 | 
         
            -
                  - id: isort
         
     | 
| 40 | 
         
            -
                    name: Format imports
         
     | 
| 41 | 
         
            -
             
     | 
| 42 | 
         
            -
              - repo: https://github.com/psf/black
         
     | 
| 43 | 
         
            -
                rev: 22.12.0
         
     | 
| 44 | 
         
            -
                hooks:
         
     | 
| 45 | 
         
            -
                  - id: black
         
     | 
| 46 | 
         
            -
                    name: Format code
         
     | 
| 47 | 
         
            -
                    additional_dependencies: ['click==8.0.2']
         
     | 
| 48 | 
         
            -
             
     | 
| 49 | 
         
            -
              - repo: https://github.com/charliermarsh/ruff-pre-commit
         
     | 
| 50 | 
         
            -
                # Ruff version.
         
     | 
| 51 | 
         
            -
                rev: 'v0.0.267'
         
     | 
| 52 | 
         
            -
                hooks:
         
     | 
| 53 | 
         
            -
                  - id: ruff
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        Makefile
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            .PHONY: style format
         
     | 
| 2 | 
         
            -
             
     | 
| 3 | 
         
            -
             
     | 
| 4 | 
         
            -
            style:
         
     | 
| 5 | 
         
            -
            	python -m black --line-length 119 .
         
     | 
| 6 | 
         
            -
            	python -m isort .
         
     | 
| 7 | 
         
            -
            	ruff check --fix .
         
     | 
| 8 | 
         
            -
             
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
            -
            quality:
         
     | 
| 11 | 
         
            -
            	python -m black --check --line-length 119 .
         
     | 
| 12 | 
         
            -
            	python -m isort --check-only .
         
     | 
| 13 | 
         
            -
            	ruff check .
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        README.md
    CHANGED
    
    | 
         @@ -1,44 +1,13 @@ 
     | 
|
| 1 | 
         
             
            ---
         
     | 
| 2 | 
         
            -
            title: The Arabic  
     | 
| 3 | 
         
            -
            emoji:  
     | 
| 4 | 
         
             
            colorFrom: green
         
     | 
| 5 | 
         
             
            colorTo: indigo
         
     | 
| 6 | 
         
             
            sdk: gradio
         
     | 
| 
         | 
|
| 7 | 
         
             
            app_file: app.py
         
     | 
| 8 | 
         
             
            pinned: true
         
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
             
            ---
         
     | 
| 11 | 
         | 
| 12 | 
         
            -
             
     | 
| 13 | 
         
            -
             
     | 
| 14 | 
         
            -
            Most of the variables to change for a default leaderboard are in `src/env.py` (replace the path for your leaderboard) and `src/about.py` (for tasks).
         
     | 
| 15 | 
         
            -
             
     | 
| 16 | 
         
            -
            Results files should have the following format and be stored as json files:
         
     | 
| 17 | 
         
            -
            ```json
         
     | 
| 18 | 
         
            -
            {
         
     | 
| 19 | 
         
            -
                "config": {
         
     | 
| 20 | 
         
            -
                    "model_dtype": "torch.float16", # or torch.bfloat16 or 8bit or 4bit
         
     | 
| 21 | 
         
            -
                    "model_name": "path of the model on the hub: org/model",
         
     | 
| 22 | 
         
            -
                    "model_sha": "revision on the hub",
         
     | 
| 23 | 
         
            -
                },
         
     | 
| 24 | 
         
            -
                "results": {
         
     | 
| 25 | 
         
            -
                    "task_name": {
         
     | 
| 26 | 
         
            -
                        "metric_name": score,
         
     | 
| 27 | 
         
            -
                    },
         
     | 
| 28 | 
         
            -
                    "task_name2": {
         
     | 
| 29 | 
         
            -
                        "metric_name": score,
         
     | 
| 30 | 
         
            -
                    }
         
     | 
| 31 | 
         
            -
                }
         
     | 
| 32 | 
         
            -
            }
         
     | 
| 33 | 
         
            -
            ```
         
     | 
| 34 | 
         
            -
             
     | 
| 35 | 
         
            -
            Request files are created automatically by this tool.
         
     | 
| 36 | 
         
            -
             
     | 
| 37 | 
         
            -
            If you encounter problem on the space, don't hesitate to restart it to remove the create eval-queue, eval-queue-bk, eval-results and eval-results-bk created folder.
         
     | 
| 38 | 
         
            -
             
     | 
| 39 | 
         
            -
            # Code logic for more complex edits
         
     | 
| 40 | 
         
            -
             
     | 
| 41 | 
         
            -
            You'll find 
         
     | 
| 42 | 
         
            -
            - the main table' columns names and properties in `src/display/utils.py`
         
     | 
| 43 | 
         
            -
            - the logic to read all results and request files, then convert them in dataframe lines, in `src/leaderboard/read_evals.py`, and `src/populate.py`
         
     | 
| 44 | 
         
            -
            - the logic to allow or filter submissions in `src/submission/submit.py` and `src/submission/check_validity.py`
         
     | 
| 
         | 
|
| 1 | 
         
             
            ---
         
     | 
| 2 | 
         
            +
            title: The Arabic RAG Leaderboard
         
     | 
| 3 | 
         
            +
            emoji: 📊
         
     | 
| 4 | 
         
             
            colorFrom: green
         
     | 
| 5 | 
         
             
            colorTo: indigo
         
     | 
| 6 | 
         
             
            sdk: gradio
         
     | 
| 7 | 
         
            +
            sdk_version: 5.7.1
         
     | 
| 8 | 
         
             
            app_file: app.py
         
     | 
| 9 | 
         
             
            pinned: true
         
     | 
| 10 | 
         
            +
            short_description: The only leaderboard you will require for your RAG needs 🏆
         
     | 
| 11 | 
         
             
            ---
         
     | 
| 12 | 
         | 
| 13 | 
         
            +
            Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        app.py
    CHANGED
    
    | 
         @@ -1,204 +1,668 @@ 
     | 
|
| 1 | 
         
            -
            import  
     | 
| 2 | 
         
            -
             
     | 
| 
         | 
|
| 3 | 
         
             
            import pandas as pd
         
     | 
| 4 | 
         
            -
             
     | 
| 5 | 
         
            -
            from huggingface_hub import  
     | 
| 6 | 
         
            -
             
     | 
| 7 | 
         
            -
             
     | 
| 8 | 
         
            -
             
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
            -
             
     | 
| 11 | 
         
            -
             
     | 
| 12 | 
         
            -
                 
     | 
| 13 | 
         
            -
                 
     | 
| 14 | 
         
            -
             
     | 
| 15 | 
         
            -
             
     | 
| 16 | 
         
            -
             
     | 
| 17 | 
         
            -
             
     | 
| 18 | 
         
            -
             
     | 
| 19 | 
         
            -
             
     | 
| 20 | 
         
            -
             
     | 
| 21 | 
         
            -
             
     | 
| 22 | 
         
            -
             
     | 
| 23 | 
         
            -
             
     | 
| 24 | 
         
            -
             
     | 
| 25 | 
         
            -
             
     | 
| 26 | 
         
            -
             
     | 
| 27 | 
         
            -
             
     | 
| 28 | 
         
            -
             
     | 
| 29 | 
         
            -
             
     | 
| 30 | 
         
            -
             
     | 
| 31 | 
         
            -
             
     | 
| 32 | 
         
            -
             
     | 
| 33 | 
         
            -
             
     | 
| 34 | 
         
            -
             
     | 
| 35 | 
         
            -
             
     | 
| 36 | 
         
            -
             
     | 
| 37 | 
         
            -
             
     | 
| 38 | 
         
            -
             
     | 
| 39 | 
         
            -
             
     | 
| 40 | 
         
            -
             
     | 
| 41 | 
         
            -
             
     | 
| 42 | 
         
            -
             
     | 
| 43 | 
         
            -
             
     | 
| 44 | 
         
            -
             
     | 
| 45 | 
         
            -
             
     | 
| 46 | 
         
            -
             
     | 
| 47 | 
         
            -
             
     | 
| 48 | 
         
            -
             
     | 
| 49 | 
         
            -
             
     | 
| 50 | 
         
            -
             
     | 
| 51 | 
         
            -
             
     | 
| 52 | 
         
            -
             
     | 
| 53 | 
         
            -
             
     | 
| 54 | 
         
            -
            (
         
     | 
| 55 | 
         
            -
                 
     | 
| 56 | 
         
            -
                 
     | 
| 57 | 
         
            -
                 
     | 
| 58 | 
         
            -
             
     | 
| 59 | 
         
            -
             
     | 
| 60 | 
         
            -
             
     | 
| 61 | 
         
            -
                 
     | 
| 62 | 
         
            -
             
     | 
| 63 | 
         
            -
             
     | 
| 64 | 
         
            -
                     
     | 
| 65 | 
         
            -
             
     | 
| 66 | 
         
            -
                     
     | 
| 67 | 
         
            -
             
     | 
| 68 | 
         
            -
             
     | 
| 69 | 
         
            -
             
     | 
| 70 | 
         
            -
             
     | 
| 71 | 
         
            -
             
     | 
| 72 | 
         
            -
             
     | 
| 73 | 
         
            -
             
     | 
| 74 | 
         
            -
             
     | 
| 75 | 
         
            -
             
     | 
| 76 | 
         
            -
             
     | 
| 77 | 
         
            -
             
     | 
| 78 | 
         
            -
             
     | 
| 79 | 
         
            -
             
     | 
| 80 | 
         
            -
             
     | 
| 81 | 
         
            -
             
     | 
| 82 | 
         
            -
             
     | 
| 83 | 
         
            -
             
     | 
| 84 | 
         
            -
             
     | 
| 85 | 
         
            -
                        ) 
     | 
| 86 | 
         
            -
                     
     | 
| 87 | 
         
            -
             
     | 
| 88 | 
         
            -
                     
     | 
| 89 | 
         
            -
             
     | 
| 90 | 
         
            -
             
     | 
| 91 | 
         
            -
             
     | 
| 92 | 
         
            -
             
     | 
| 93 | 
         
            -
             
     | 
| 94 | 
         
            -
             
     | 
| 95 | 
         
            -
             
     | 
| 96 | 
         
            -
             
     | 
| 97 | 
         
            -
             
     | 
| 98 | 
         
            -
                     
     | 
| 99 | 
         
            -
             
     | 
| 100 | 
         
            -
             
     | 
| 101 | 
         
            -
             
     | 
| 102 | 
         
            -
                         
     | 
| 103 | 
         
            -
             
     | 
| 104 | 
         
            -
             
     | 
| 105 | 
         
            -
                         
     | 
| 106 | 
         
            -
             
     | 
| 107 | 
         
            -
             
     | 
| 108 | 
         
            -
             
     | 
| 109 | 
         
            -
             
     | 
| 110 | 
         
            -
             
     | 
| 111 | 
         
            -
             
     | 
| 112 | 
         
            -
             
     | 
| 113 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 114 | 
         
             
                                    with gr.Row():
         
     | 
| 115 | 
         
            -
                                         
     | 
| 116 | 
         
            -
                                             
     | 
| 117 | 
         
            -
                                             
     | 
| 118 | 
         
            -
                                             
     | 
| 119 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 120 | 
         
             
                                        )
         
     | 
| 121 | 
         
            -
                                with gr.Accordion(
         
     | 
| 122 | 
         
            -
                                    f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
         
     | 
| 123 | 
         
            -
                                    open=False,
         
     | 
| 124 | 
         
            -
                                ):
         
     | 
| 125 | 
         
             
                                    with gr.Row():
         
     | 
| 126 | 
         
            -
                                         
     | 
| 127 | 
         
            -
                                             
     | 
| 128 | 
         
            -
                                             
     | 
| 129 | 
         
            -
                                             
     | 
| 130 | 
         
            -
                                             
     | 
| 
         | 
|
| 
         | 
|
| 131 | 
         
             
                                        )
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 132 | 
         | 
| 133 | 
         
            -
             
     | 
| 134 | 
         
            -
                                     
     | 
| 135 | 
         
            -
                                    open=False 
     | 
| 136 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 137 | 
         
             
                                    with gr.Row():
         
     | 
| 138 | 
         
            -
                                         
     | 
| 139 | 
         
            -
                                             
     | 
| 140 | 
         
            -
                                             
     | 
| 141 | 
         
            -
                                             
     | 
| 142 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 143 | 
         
             
                                        )
         
     | 
| 144 | 
         
            -
                        with gr.Row():
         
     | 
| 145 | 
         
            -
                            gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
         
     | 
| 146 | 
         | 
| 147 | 
         
            -
             
     | 
| 148 | 
         
            -
             
     | 
| 149 | 
         
            -
                                model_name_textbox = gr.Textbox(label="Model name")
         
     | 
| 150 | 
         
            -
                                revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
         
     | 
| 151 | 
         
            -
                                model_type = gr.Dropdown(
         
     | 
| 152 | 
         
            -
                                    choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
         
     | 
| 153 | 
         
            -
                                    label="Model type",
         
     | 
| 154 | 
         
            -
                                    multiselect=False,
         
     | 
| 155 | 
         
            -
                                    value=None,
         
     | 
| 156 | 
         
            -
                                    interactive=True,
         
     | 
| 157 | 
         
            -
                                )
         
     | 
| 158 | 
         | 
| 159 | 
         
            -
             
     | 
| 160 | 
         
            -
             
     | 
| 161 | 
         
            -
             
     | 
| 162 | 
         
            -
                                     
     | 
| 163 | 
         
            -
             
     | 
| 164 | 
         
            -
                                     
     | 
| 165 | 
         
            -
             
     | 
| 166 | 
         
            -
             
     | 
| 167 | 
         
            -
             
     | 
| 168 | 
         
            -
             
     | 
| 169 | 
         
            -
                                     
     | 
| 170 | 
         
            -
                                     
     | 
| 171 | 
         
            -
                                     
     | 
| 172 | 
         
            -
                                     
     | 
| 
         | 
|
| 173 | 
         
             
                                )
         
     | 
| 174 | 
         
            -
                                base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
         
     | 
| 175 | 
         
            -
             
     | 
| 176 | 
         
            -
                        submit_button = gr.Button("Submit Eval")
         
     | 
| 177 | 
         
            -
                        submission_result = gr.Markdown()
         
     | 
| 178 | 
         
            -
                        submit_button.click(
         
     | 
| 179 | 
         
            -
                            add_new_eval,
         
     | 
| 180 | 
         
            -
                            [
         
     | 
| 181 | 
         
            -
                                model_name_textbox,
         
     | 
| 182 | 
         
            -
                                base_model_name_textbox,
         
     | 
| 183 | 
         
            -
                                revision_name_textbox,
         
     | 
| 184 | 
         
            -
                                precision,
         
     | 
| 185 | 
         
            -
                                weight_type,
         
     | 
| 186 | 
         
            -
                                model_type,
         
     | 
| 187 | 
         
            -
                            ],
         
     | 
| 188 | 
         
            -
                            submission_result,
         
     | 
| 189 | 
         
            -
                        )
         
     | 
| 190 | 
         | 
| 191 | 
         
            -
                 
     | 
| 192 | 
         
            -
                    with gr.Accordion("📙 Citation", open=False):
         
     | 
| 193 | 
         
            -
                        citation_button = gr.Textbox(
         
     | 
| 194 | 
         
            -
                            value=CITATION_BUTTON_TEXT,
         
     | 
| 195 | 
         
            -
                            label=CITATION_BUTTON_LABEL,
         
     | 
| 196 | 
         
            -
                            lines=20,
         
     | 
| 197 | 
         
            -
                            elem_id="citation-button",
         
     | 
| 198 | 
         
            -
                            show_copy_button=True,
         
     | 
| 199 | 
         
            -
                        )
         
     | 
| 200 | 
         | 
| 201 | 
         
            -
             
     | 
| 202 | 
         
            -
             
     | 
| 203 | 
         
            -
            scheduler.start()
         
     | 
| 204 | 
         
            -
            demo.queue(default_concurrency_limit=40).launch()
         
     | 
| 
         | 
|
| 1 | 
         
            +
            import os
         
     | 
| 2 | 
         
            +
            import json
         
     | 
| 3 | 
         
            +
            import numpy as np
         
     | 
| 4 | 
         
             
            import pandas as pd
         
     | 
| 5 | 
         
            +
            import gradio as gr
         
     | 
| 6 | 
         
            +
            from huggingface_hub import HfApi, hf_hub_download
         
     | 
| 7 | 
         
            +
             
     | 
| 8 | 
         
            +
             
     | 
| 9 | 
         
            +
            OWNER = "Navid-AI"
         
     | 
| 10 | 
         
            +
            DATASET_REPO_ID = f"{OWNER}/requests-dataset"
         
     | 
| 11 | 
         
            +
             
     | 
| 12 | 
         
            +
            HEADER = """<div style="text-align: center; margin-bottom: 20px;">
         
     | 
| 13 | 
         
            +
                <h1>The Arabic RAG Leaderboard</h1>
         
     | 
| 14 | 
         
            +
                <p style="font-size: 14px; color: #888;">The only leaderboard you will require for your RAG needs 🏆</p>
         
     | 
| 15 | 
         
            +
            </div>
         
     | 
| 16 | 
         
            +
             
     | 
| 17 | 
         
            +
            """
         
     | 
| 18 | 
         
            +
             
     | 
| 19 | 
         
            +
            ABOUT_SECTION = """
         
     | 
| 20 | 
         
            +
            ## About
         
     | 
| 21 | 
         
            +
             
     | 
| 22 | 
         
            +
            The AraGen Leaderboard is designed to evaluate and compare the performance of Chat Arabic Large Language Models (LLMs) on a set of generative tasks. By leveraging the new **3C3H** evaluation measure which evaluate the model's output across six dimensions —Correctness, Completeness, Conciseness, Helpfulness, Honesty, and Harmlessness— the leaderboard provides a comprehensive and holistic evaluation of a model's performance in generating human-like and ethically responsible content.
         
     | 
| 23 | 
         
            +
             
     | 
| 24 | 
         
            +
            ### Why Focus on Chat Models?
         
     | 
| 25 | 
         
            +
             
     | 
| 26 | 
         
            +
            AraGen Leaderboard —And 3C3H in general— is specifically designed to assess **chat models**, which interact in conversational settings, intended for end user interaction and require a blend of factual accuracy and user-centric dialogue capabilities. While it is technically possible to submit foundational models, we kindly ask users to refrain from doing so. For evaluations of foundational models using likelihood accuracy based benchmarks, please refer to the [Open Arabic LLM Leaderboard (OALL)](https://huggingface.co/spaces/OALL/Open-Arabic-LLM-Leaderboard).
         
     | 
| 27 | 
         
            +
             
     | 
| 28 | 
         
            +
            ### How to Submit Your Model?
         
     | 
| 29 | 
         
            +
             
     | 
| 30 | 
         
            +
            Navigate to the submission section below to submit your open chat model from the HuggingFace Hub for evaluation. Ensure that your model is public and the submmited metadata (precision, revision, #params) is accurate.
         
     | 
| 31 | 
         
            +
             
     | 
| 32 | 
         
            +
            ### Contact
         
     | 
| 33 | 
         
            +
             
     | 
| 34 | 
         
            +
            For any inquiries or assistance, feel free to reach out through the community tab at [Inception AraGen Community](https://huggingface.co/spaces/inceptionai/AraGen-Leaderboard/discussions) or via [email](mailto:[email protected]).
         
     | 
| 35 | 
         
            +
            """
         
     | 
| 36 | 
         
            +
             
     | 
| 37 | 
         
            +
            CITATION_BUTTON_LABEL = """
         
     | 
| 38 | 
         
            +
            Copy the following snippet to cite these results
         
     | 
| 39 | 
         
            +
            """
         
     | 
| 40 | 
         
            +
             
     | 
| 41 | 
         
            +
            CITATION_BUTTON_TEXT = """
         
     | 
| 42 | 
         
            +
            @misc{AraGen,
         
     | 
| 43 | 
         
            +
              author = {El Filali, Ali and Sengupta, Neha and Abouelseoud, Arwa and Nakov, Preslav and Fourrier, Clémentine},
         
     | 
| 44 | 
         
            +
              title = {Rethinking LLM Evaluation with 3C3H: AraGen Benchmark and Leaderboard},
         
     | 
| 45 | 
         
            +
              year = {2024},
         
     | 
| 46 | 
         
            +
              publisher = {Inception},
         
     | 
| 47 | 
         
            +
              howpublished = "url{https://huggingface.co/spaces/inceptionai/AraGen-Leaderboard}"
         
     | 
| 48 | 
         
            +
            }
         
     | 
| 49 | 
         
            +
            """
         
     | 
| 50 | 
         
            +
             
     | 
| 51 | 
         
            +
             
     | 
| 52 | 
         
            +
            def load_results():
         
     | 
| 53 | 
         
            +
                # Get the current directory of the script and construct the path to results.json
         
     | 
| 54 | 
         
            +
                current_dir = os.path.dirname(os.path.abspath(__file__))
         
     | 
| 55 | 
         
            +
                results_file = os.path.join(current_dir, "assets", "results", "results.json")
         
     | 
| 56 | 
         
            +
                
         
     | 
| 57 | 
         
            +
                # Load the JSON data from the specified file
         
     | 
| 58 | 
         
            +
                with open(results_file, 'r') as f:
         
     | 
| 59 | 
         
            +
                    data = json.load(f)
         
     | 
| 60 | 
         
            +
                
         
     | 
| 61 | 
         
            +
                # Filter out any entries that only contain '_last_sync_timestamp'
         
     | 
| 62 | 
         
            +
                filtered_data = []
         
     | 
| 63 | 
         
            +
                for entry in data:
         
     | 
| 64 | 
         
            +
                    # If '_last_sync_timestamp' is the only key, skip it
         
     | 
| 65 | 
         
            +
                    if len(entry.keys()) == 1 and "_last_sync_timestamp" in entry:
         
     | 
| 66 | 
         
            +
                        continue
         
     | 
| 67 | 
         
            +
                    filtered_data.append(entry)
         
     | 
| 68 | 
         
            +
                
         
     | 
| 69 | 
         
            +
                data = filtered_data
         
     | 
| 70 | 
         
            +
                
         
     | 
| 71 | 
         
            +
                # Lists to collect data
         
     | 
| 72 | 
         
            +
                data_3c3h = []
         
     | 
| 73 | 
         
            +
                data_tasks = []
         
     | 
| 74 | 
         
            +
                
         
     | 
| 75 | 
         
            +
                for model_data in data:
         
     | 
| 76 | 
         
            +
                    # Extract model meta data
         
     | 
| 77 | 
         
            +
                    meta = model_data.get('Meta', {})
         
     | 
| 78 | 
         
            +
                    model_name = meta.get('Model Name', 'UNK')
         
     | 
| 79 | 
         
            +
                    revision = meta.get('Revision', 'UNK')
         
     | 
| 80 | 
         
            +
                    precision = meta.get('Precision', 'UNK')
         
     | 
| 81 | 
         
            +
                    params = meta.get('Params', 'UNK')
         
     | 
| 82 | 
         
            +
                    license = meta.get('License', 'UNK')
         
     | 
| 83 | 
         
            +
                    
         
     | 
| 84 | 
         
            +
                    # Convert "Model Size" to numeric, treating "UNK" as infinity
         
     | 
| 85 | 
         
            +
                    try:
         
     | 
| 86 | 
         
            +
                        model_size_numeric = float(params)
         
     | 
| 87 | 
         
            +
                    except (ValueError, TypeError):
         
     | 
| 88 | 
         
            +
                        model_size_numeric = np.inf
         
     | 
| 89 | 
         
            +
                    
         
     | 
| 90 | 
         
            +
                    # 3C3H Scores
         
     | 
| 91 | 
         
            +
                    scores_data = model_data.get('claude-3.5-sonnet Scores', {})
         
     | 
| 92 | 
         
            +
                    scores_3c3h = scores_data.get('3C3H Scores', {})
         
     | 
| 93 | 
         
            +
                    scores_tasks = scores_data.get('Tasks Scores', {})
         
     | 
| 94 | 
         
            +
                    
         
     | 
| 95 | 
         
            +
                    # Multiply scores by 100 to get percentages (keep them as numeric values)
         
     | 
| 96 | 
         
            +
                    formatted_scores_3c3h = {k: v*100 for k, v in scores_3c3h.items()}
         
     | 
| 97 | 
         
            +
                    formatted_scores_tasks = {k: v*100 for k, v in scores_tasks.items()}
         
     | 
| 98 | 
         
            +
                    
         
     | 
| 99 | 
         
            +
                    # For 3C3H Scores DataFrame
         
     | 
| 100 | 
         
            +
                    data_entry_3c3h = {
         
     | 
| 101 | 
         
            +
                        'Model Name': model_name,
         
     | 
| 102 | 
         
            +
                        'Revision': revision,
         
     | 
| 103 | 
         
            +
                        'License': license,
         
     | 
| 104 | 
         
            +
                        'Precision': precision,
         
     | 
| 105 | 
         
            +
                        'Model Size': model_size_numeric,  # Numeric value for sorting
         
     | 
| 106 | 
         
            +
                        '3C3H Score': formatted_scores_3c3h.get("3C3H Score", np.nan),
         
     | 
| 107 | 
         
            +
                        'Correctness': formatted_scores_3c3h.get("Correctness", np.nan),
         
     | 
| 108 | 
         
            +
                        'Completeness': formatted_scores_3c3h.get("Completeness", np.nan),
         
     | 
| 109 | 
         
            +
                        'Conciseness': formatted_scores_3c3h.get("Conciseness", np.nan),
         
     | 
| 110 | 
         
            +
                        'Helpfulness': formatted_scores_3c3h.get("Helpfulness", np.nan),
         
     | 
| 111 | 
         
            +
                        'Honesty': formatted_scores_3c3h.get("Honesty", np.nan),
         
     | 
| 112 | 
         
            +
                        'Harmlessness': formatted_scores_3c3h.get("Harmlessness", np.nan),
         
     | 
| 113 | 
         
            +
                    }
         
     | 
| 114 | 
         
            +
                    data_3c3h.append(data_entry_3c3h)
         
     | 
| 115 | 
         
            +
                    
         
     | 
| 116 | 
         
            +
                    # For Tasks Scores DataFrame
         
     | 
| 117 | 
         
            +
                    data_entry_tasks = {
         
     | 
| 118 | 
         
            +
                        'Model Name': model_name,
         
     | 
| 119 | 
         
            +
                        'Revision': revision,
         
     | 
| 120 | 
         
            +
                        'License': license,
         
     | 
| 121 | 
         
            +
                        'Precision': precision,
         
     | 
| 122 | 
         
            +
                        'Model Size': model_size_numeric,  # Numeric value for sorting
         
     | 
| 123 | 
         
            +
                        **formatted_scores_tasks
         
     | 
| 124 | 
         
            +
                    }
         
     | 
| 125 | 
         
            +
                    data_tasks.append(data_entry_tasks)
         
     | 
| 126 | 
         
            +
                
         
     | 
| 127 | 
         
            +
                df_3c3h = pd.DataFrame(data_3c3h)
         
     | 
| 128 | 
         
            +
                df_tasks = pd.DataFrame(data_tasks)
         
     | 
| 129 | 
         
            +
                
         
     | 
| 130 | 
         
            +
                # Round the numeric score columns to 4 decimal places
         
     | 
| 131 | 
         
            +
                score_columns_3c3h = ['3C3H Score', 'Correctness', 'Completeness', 'Conciseness', 'Helpfulness', 'Honesty', 'Harmlessness']
         
     | 
| 132 | 
         
            +
                df_3c3h[score_columns_3c3h] = df_3c3h[score_columns_3c3h].round(4)
         
     | 
| 133 | 
         
            +
                
         
     | 
| 134 | 
         
            +
                # Replace np.inf with a large number in 'Model Size Filter' for filtering
         
     | 
| 135 | 
         
            +
                max_model_size_value = 1000  # Define a maximum value
         
     | 
| 136 | 
         
            +
                df_3c3h['Model Size Filter'] = df_3c3h['Model Size'].replace(np.inf, max_model_size_value)
         
     | 
| 137 | 
         
            +
                
         
     | 
| 138 | 
         
            +
                # Sort df_3c3h by '3C3H Score' descending if column exists
         
     | 
| 139 | 
         
            +
                if '3C3H Score' in df_3c3h.columns:
         
     | 
| 140 | 
         
            +
                    df_3c3h = df_3c3h.sort_values(by='3C3H Score', ascending=False)
         
     | 
| 141 | 
         
            +
                    df_3c3h.insert(0, 'Rank', range(1, len(df_3c3h) + 1))  # Add Rank column starting from 1
         
     | 
| 142 | 
         
            +
                else:
         
     | 
| 143 | 
         
            +
                    df_3c3h.insert(0, 'Rank', range(1, len(df_3c3h) + 1))
         
     | 
| 144 | 
         
            +
                
         
     | 
| 145 | 
         
            +
                # Extract task columns
         
     | 
| 146 | 
         
            +
                task_columns = [col for col in df_tasks.columns if col not in ['Model Name', 'Revision', 'License', 'Precision', 'Model Size', 'Model Size Filter']]
         
     | 
| 147 | 
         
            +
                
         
     | 
| 148 | 
         
            +
                # Round the task score columns to 4 decimal places
         
     | 
| 149 | 
         
            +
                if task_columns:
         
     | 
| 150 | 
         
            +
                    df_tasks[task_columns] = df_tasks[task_columns].round(4)
         
     | 
| 151 | 
         
            +
                
         
     | 
| 152 | 
         
            +
                # Replace np.inf with a large number in 'Model Size Filter' for filtering
         
     | 
| 153 | 
         
            +
                df_tasks['Model Size Filter'] = df_tasks['Model Size'].replace(np.inf, max_model_size_value)
         
     | 
| 154 | 
         
            +
                
         
     | 
| 155 | 
         
            +
                # Sort df_tasks by the first task column if it exists
         
     | 
| 156 | 
         
            +
                if task_columns:
         
     | 
| 157 | 
         
            +
                    first_task = task_columns[0]
         
     | 
| 158 | 
         
            +
                    df_tasks = df_tasks.sort_values(by=first_task, ascending=False)
         
     | 
| 159 | 
         
            +
                    df_tasks.insert(0, 'Rank', range(1, len(df_tasks) + 1))  # Add Rank column starting from 1
         
     | 
| 160 | 
         
            +
                else:
         
     | 
| 161 | 
         
            +
                    df_tasks = df_tasks.sort_values(by='Model Name', ascending=True)
         
     | 
| 162 | 
         
            +
                    df_tasks.insert(0, 'Rank', range(1, len(df_tasks) + 1))
         
     | 
| 163 | 
         
            +
                
         
     | 
| 164 | 
         
            +
                return df_3c3h, df_tasks, task_columns
         
     | 
| 165 | 
         
            +
             
     | 
| 166 | 
         
            +
            def load_requests(status_folder):
         
     | 
| 167 | 
         
            +
                api = HfApi()
         
     | 
| 168 | 
         
            +
                requests_data = []
         
     | 
| 169 | 
         
            +
                folder_path_in_repo = status_folder  # 'pending', 'finished', or 'failed'
         
     | 
| 170 | 
         
            +
             
     | 
| 171 | 
         
            +
                hf_api_token = os.environ.get('HF_API_TOKEN', None)
         
     | 
| 172 | 
         
            +
             
     | 
| 173 | 
         
            +
                try:
         
     | 
| 174 | 
         
            +
                    # List files in the dataset repository
         
     | 
| 175 | 
         
            +
                    files_info = api.list_repo_files(
         
     | 
| 176 | 
         
            +
                        repo_id=DATASET_REPO_ID,
         
     | 
| 177 | 
         
            +
                        repo_type="dataset",
         
     | 
| 178 | 
         
            +
                        token=hf_api_token
         
     | 
| 179 | 
         
            +
                    )
         
     | 
| 180 | 
         
            +
                except Exception as e:
         
     | 
| 181 | 
         
            +
                    print(f"Error accessing dataset repository: {e}")
         
     | 
| 182 | 
         
            +
                    return pd.DataFrame()  # Return empty DataFrame if repository not found or inaccessible
         
     | 
| 183 | 
         
            +
             
     | 
| 184 | 
         
            +
                # Filter files in the desired folder
         
     | 
| 185 | 
         
            +
                files_in_folder = [f for f in files_info if f.startswith(f"{folder_path_in_repo}/") and f.endswith('.json')]
         
     | 
| 186 | 
         
            +
             
     | 
| 187 | 
         
            +
                for file_path in files_in_folder:
         
     | 
| 188 | 
         
            +
                    try:
         
     | 
| 189 | 
         
            +
                        # Download the JSON file
         
     | 
| 190 | 
         
            +
                        local_file_path = hf_hub_download(
         
     | 
| 191 | 
         
            +
                            repo_id=DATASET_REPO_ID,
         
     | 
| 192 | 
         
            +
                            filename=file_path,
         
     | 
| 193 | 
         
            +
                            repo_type="dataset",
         
     | 
| 194 | 
         
            +
                            token=hf_api_token
         
     | 
| 195 | 
         
            +
                        )
         
     | 
| 196 | 
         
            +
                        # Load JSON data
         
     | 
| 197 | 
         
            +
                        with open(local_file_path, 'r') as f:
         
     | 
| 198 | 
         
            +
                            request = json.load(f)
         
     | 
| 199 | 
         
            +
                        requests_data.append(request)
         
     | 
| 200 | 
         
            +
                    except Exception as e:
         
     | 
| 201 | 
         
            +
                        print(f"Error loading file {file_path}: {e}")
         
     | 
| 202 | 
         
            +
                        continue  # Skip files that can't be loaded
         
     | 
| 203 | 
         
            +
             
     | 
| 204 | 
         
            +
                df = pd.DataFrame(requests_data)
         
     | 
| 205 | 
         
            +
                return df
         
     | 
| 206 | 
         
            +
             
     | 
| 207 | 
         
            +
            def submit_model(model_name, revision, precision, params, license):
         
     | 
| 208 | 
         
            +
                # Load existing evaluations
         
     | 
| 209 | 
         
            +
                df_3c3h, df_tasks, _ = load_results()
         
     | 
| 210 | 
         
            +
                existing_models_results = df_3c3h[['Model Name', 'Revision', 'Precision']]
         
     | 
| 211 | 
         
            +
             
     | 
| 212 | 
         
            +
                # Handle 'Missing' precision
         
     | 
| 213 | 
         
            +
                if precision == 'Missing':
         
     | 
| 214 | 
         
            +
                    precision = None
         
     | 
| 215 | 
         
            +
                else:
         
     | 
| 216 | 
         
            +
                    precision = precision.strip().lower()
         
     | 
| 217 | 
         
            +
             
     | 
| 218 | 
         
            +
                # Load pending and finished requests from the dataset repository
         
     | 
| 219 | 
         
            +
                df_pending = load_requests('pending')
         
     | 
| 220 | 
         
            +
                df_finished = load_requests('finished')
         
     | 
| 221 | 
         
            +
             
     | 
| 222 | 
         
            +
                # Check if model is already evaluated
         
     | 
| 223 | 
         
            +
                model_exists_in_results = ((existing_models_results['Model Name'] == model_name) &
         
     | 
| 224 | 
         
            +
                                           (existing_models_results['Revision'] == revision) &
         
     | 
| 225 | 
         
            +
                                           (existing_models_results['Precision'] == precision)).any()
         
     | 
| 226 | 
         
            +
                if model_exists_in_results:
         
     | 
| 227 | 
         
            +
                    return f"**Model '{model_name}' with revision '{revision}' and precision '{precision}' has already been evaluated.**"
         
     | 
| 228 | 
         
            +
             
     | 
| 229 | 
         
            +
                # Check if model is in pending requests
         
     | 
| 230 | 
         
            +
                if not df_pending.empty:
         
     | 
| 231 | 
         
            +
                    existing_models_pending = df_pending[['model_name', 'revision', 'precision']]
         
     | 
| 232 | 
         
            +
                    model_exists_in_pending = ((existing_models_pending['model_name'] == model_name) &
         
     | 
| 233 | 
         
            +
                                               (existing_models_pending['revision'] == revision) &
         
     | 
| 234 | 
         
            +
                                               (existing_models_pending['precision'] == precision)).any()
         
     | 
| 235 | 
         
            +
                    if model_exists_in_pending:
         
     | 
| 236 | 
         
            +
                        return f"**Model '{model_name}' with revision '{revision}' and precision '{precision}' is already in the pending evaluations.**"
         
     | 
| 237 | 
         
            +
             
     | 
| 238 | 
         
            +
                # Check if model is in finished requests
         
     | 
| 239 | 
         
            +
                if not df_finished.empty:
         
     | 
| 240 | 
         
            +
                    existing_models_finished = df_finished[['model_name', 'revision', 'precision']]
         
     | 
| 241 | 
         
            +
                    model_exists_in_finished = ((existing_models_finished['model_name'] == model_name) &
         
     | 
| 242 | 
         
            +
                                                (existing_models_finished['revision'] == revision) &
         
     | 
| 243 | 
         
            +
                                                (existing_models_finished['precision'] == precision)).any()
         
     | 
| 244 | 
         
            +
                    if model_exists_in_finished:
         
     | 
| 245 | 
         
            +
                        return f"**Model '{model_name}' with revision '{revision}' and precision '{precision}' has already been evaluated.**"
         
     | 
| 246 | 
         
            +
             
     | 
| 247 | 
         
            +
                # Check if model exists on HuggingFace Hub
         
     | 
| 248 | 
         
            +
                api = HfApi()
         
     | 
| 249 | 
         
            +
                try:
         
     | 
| 250 | 
         
            +
                    model_info = api.model_info(model_name)
         
     | 
| 251 | 
         
            +
                except Exception as e:
         
     | 
| 252 | 
         
            +
                    return f"**Error: Could not find model '{model_name}' on HuggingFace Hub. Please ensure the model name is correct and the model is public.**"
         
     | 
| 253 | 
         
            +
             
     | 
| 254 | 
         
            +
                # Proceed with submission
         
     | 
| 255 | 
         
            +
                status = "PENDING"
         
     | 
| 256 | 
         
            +
             
     | 
| 257 | 
         
            +
                # Prepare the submission data
         
     | 
| 258 | 
         
            +
                submission = {
         
     | 
| 259 | 
         
            +
                    "model_name": model_name,
         
     | 
| 260 | 
         
            +
                    "license": license,
         
     | 
| 261 | 
         
            +
                    "revision": revision,
         
     | 
| 262 | 
         
            +
                    "precision": precision,
         
     | 
| 263 | 
         
            +
                    "status": status,
         
     | 
| 264 | 
         
            +
                    "params": params
         
     | 
| 265 | 
         
            +
                }
         
     | 
| 266 | 
         
            +
             
     | 
| 267 | 
         
            +
                # Serialize the submission to JSON
         
     | 
| 268 | 
         
            +
                submission_json = json.dumps(submission, indent=2)
         
     | 
| 269 | 
         
            +
             
     | 
| 270 | 
         
            +
                # Define the file path in the repository
         
     | 
| 271 | 
         
            +
                org_model = model_name.split('/')
         
     | 
| 272 | 
         
            +
                if len(org_model) != 2:
         
     | 
| 273 | 
         
            +
                    return "**Please enter the full model name including the organization or username, e.g., 'inceptionai/jais-family-30b-8k'**"
         
     | 
| 274 | 
         
            +
                org, model_id = org_model
         
     | 
| 275 | 
         
            +
                precision_str = precision if precision else 'Missing'
         
     | 
| 276 | 
         
            +
                file_path_in_repo = f"pending/{org}/{model_id}_eval_request_{revision}_{precision_str}.json"
         
     | 
| 277 | 
         
            +
             
     | 
| 278 | 
         
            +
                # Upload the submission to the dataset repository
         
     | 
| 279 | 
         
            +
                try:
         
     | 
| 280 | 
         
            +
                    hf_api_token = os.environ.get('HF_API_TOKEN', None)
         
     | 
| 281 | 
         
            +
                    api.upload_file(
         
     | 
| 282 | 
         
            +
                        path_or_fileobj=submission_json.encode('utf-8'),
         
     | 
| 283 | 
         
            +
                        path_in_repo=file_path_in_repo,
         
     | 
| 284 | 
         
            +
                        repo_id=DATASET_REPO_ID,
         
     | 
| 285 | 
         
            +
                        repo_type="dataset",
         
     | 
| 286 | 
         
            +
                        token=hf_api_token
         
     | 
| 287 | 
         
            +
                    )
         
     | 
| 288 | 
         
            +
                except Exception as e:
         
     | 
| 289 | 
         
            +
                    return f"**Error: Could not submit the model. {str(e)}**"
         
     | 
| 290 | 
         
            +
             
     | 
| 291 | 
         
            +
                return f"**Model '{model_name}' has been submitted for evaluation.**"
         
     | 
| 292 | 
         
            +
             
     | 
| 293 | 
         
            +
            def main():
         
     | 
| 294 | 
         
            +
                df_3c3h, df_tasks, task_columns = load_results()
         
     | 
| 295 | 
         
            +
             
     | 
| 296 | 
         
            +
                # Extract unique Precision and License values for filters
         
     | 
| 297 | 
         
            +
                precision_options_3c3h = sorted(df_3c3h['Precision'].dropna().unique().tolist())
         
     | 
| 298 | 
         
            +
                precision_options_3c3h = [p for p in precision_options_3c3h if p != 'UNK']
         
     | 
| 299 | 
         
            +
                precision_options_3c3h.append('Missing')
         
     | 
| 300 | 
         
            +
             
     | 
| 301 | 
         
            +
                license_options_3c3h = sorted(df_3c3h['License'].dropna().unique().tolist())
         
     | 
| 302 | 
         
            +
                license_options_3c3h = [l for l in license_options_3c3h if l != 'UNK']
         
     | 
| 303 | 
         
            +
                license_options_3c3h.append('Missing')
         
     | 
| 304 | 
         
            +
             
     | 
| 305 | 
         
            +
                precision_options_tasks = sorted(df_tasks['Precision'].dropna().unique().tolist())
         
     | 
| 306 | 
         
            +
                precision_options_tasks = [p for p in precision_options_tasks if p != 'UNK']
         
     | 
| 307 | 
         
            +
                precision_options_tasks.append('Missing')
         
     | 
| 308 | 
         
            +
             
     | 
| 309 | 
         
            +
                license_options_tasks = sorted(df_tasks['License'].dropna().unique().tolist())
         
     | 
| 310 | 
         
            +
                license_options_tasks = [l for l in license_options_tasks if l != 'UNK']
         
     | 
| 311 | 
         
            +
                license_options_tasks.append('Missing')
         
     | 
| 312 | 
         
            +
             
     | 
| 313 | 
         
            +
                # Get min and max model sizes for sliders, handling 'inf' values
         
     | 
| 314 | 
         
            +
                min_model_size_3c3h = int(df_3c3h['Model Size Filter'].min())
         
     | 
| 315 | 
         
            +
                max_model_size_3c3h = int(df_3c3h['Model Size Filter'].max())
         
     | 
| 316 | 
         
            +
             
     | 
| 317 | 
         
            +
                min_model_size_tasks = int(df_tasks['Model Size Filter'].min())
         
     | 
| 318 | 
         
            +
                max_model_size_tasks = int(df_tasks['Model Size Filter'].max())
         
     | 
| 319 | 
         
            +
             
     | 
| 320 | 
         
            +
                # Exclude 'Model Size Filter' from column selectors
         
     | 
| 321 | 
         
            +
                column_choices_3c3h = [col for col in df_3c3h.columns if col != 'Model Size Filter']
         
     | 
| 322 | 
         
            +
                column_choices_tasks = [col for col in df_tasks.columns if col != 'Model Size Filter']
         
     | 
| 323 | 
         
            +
             
     | 
| 324 | 
         
            +
                with gr.Blocks() as demo:
         
     | 
| 325 | 
         
            +
                    gr.Markdown(HEADER)
         
     | 
| 326 | 
         
            +
                    
         
     | 
| 327 | 
         
            +
                    with gr.Tabs():
         
     | 
| 328 | 
         
            +
                        with gr.Tab("Retrieval"):
         
     | 
| 329 | 
         
            +
                            with gr.Tabs():
         
     | 
| 330 | 
         
            +
                                with gr.Tab("Leaderboard"):
         
     | 
| 331 | 
         
             
                                    with gr.Row():
         
     | 
| 332 | 
         
            +
                                        search_box_retrieval = gr.Textbox(
         
     | 
| 333 | 
         
            +
                                            placeholder="Search for models...", 
         
     | 
| 334 | 
         
            +
                                            label="Search", 
         
     | 
| 335 | 
         
            +
                                            interactive=True
         
     | 
| 336 | 
         
            +
                                        )
         
     | 
| 337 | 
         
            +
             
     | 
| 338 | 
         
            +
                                    with gr.Row():
         
     | 
| 339 | 
         
            +
                                        license_filter_retrieval = gr.CheckboxGroup(
         
     | 
| 340 | 
         
            +
                                            choices=license_options_3c3h,
         
     | 
| 341 | 
         
            +
                                            value=license_options_3c3h.copy(),  # Default all selected
         
     | 
| 342 | 
         
            +
                                            label="Filter by License",
         
     | 
| 343 | 
         
            +
                                        )
         
     | 
| 344 | 
         
            +
                                        precision_filter_retrieval = gr.CheckboxGroup(
         
     | 
| 345 | 
         
            +
                                            choices=precision_options_3c3h,
         
     | 
| 346 | 
         
            +
                                            value=precision_options_3c3h.copy(),  # Default all selected
         
     | 
| 347 | 
         
            +
                                            label="Filter by Precision",
         
     | 
| 348 | 
         
             
                                        )
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 349 | 
         
             
                                    with gr.Row():
         
     | 
| 350 | 
         
            +
                                        model_size_min_filter_3c3h = gr.Slider(
         
     | 
| 351 | 
         
            +
                                            minimum=min_model_size_3c3h,
         
     | 
| 352 | 
         
            +
                                            maximum=max_model_size_3c3h,
         
     | 
| 353 | 
         
            +
                                            value=min_model_size_3c3h,
         
     | 
| 354 | 
         
            +
                                            step=1,
         
     | 
| 355 | 
         
            +
                                            label="Minimum Model Size",
         
     | 
| 356 | 
         
            +
                                            interactive=True
         
     | 
| 357 | 
         
             
                                        )
         
     | 
| 358 | 
         
            +
                                        model_size_max_filter_3c3h = gr.Slider(
         
     | 
| 359 | 
         
            +
                                            minimum=min_model_size_3c3h,
         
     | 
| 360 | 
         
            +
                                            maximum=max_model_size_3c3h,
         
     | 
| 361 | 
         
            +
                                            value=max_model_size_3c3h,
         
     | 
| 362 | 
         
            +
                                            step=1,
         
     | 
| 363 | 
         
            +
                                            label="Maximum Model Size",
         
     | 
| 364 | 
         
            +
                                            interactive=True
         
     | 
| 365 | 
         
            +
                                        )
         
     | 
| 366 | 
         
            +
                                    
         
     | 
| 367 | 
         
            +
                                    leaderboard_3c3h = gr.Dataframe(
         
     | 
| 368 | 
         
            +
                                        df_3c3h[['Rank', 'Model Name', '3C3H Score', 'Correctness', 'Completeness',
         
     | 
| 369 | 
         
            +
                                               'Conciseness', 'Helpfulness', 'Honesty', 'Harmlessness']],
         
     | 
| 370 | 
         
            +
                                        interactive=False
         
     | 
| 371 | 
         
            +
                                    )
         
     | 
| 372 | 
         
            +
                                    
         
     | 
| 373 | 
         
            +
                                    def filter_df_3c3h(search_query, selected_cols, precision_filters, license_filters, min_size, max_size):
         
     | 
| 374 | 
         
            +
                                        filtered_df = df_3c3h.copy()
         
     | 
| 375 | 
         
            +
                                        
         
     | 
| 376 | 
         
            +
                                        # Ensure min_size <= max_size
         
     | 
| 377 | 
         
            +
                                        if min_size > max_size:
         
     | 
| 378 | 
         
            +
                                            min_size, max_size = max_size, min_size
         
     | 
| 379 | 
         
            +
                                        
         
     | 
| 380 | 
         
            +
                                        # Apply search filter
         
     | 
| 381 | 
         
            +
                                        if search_query:
         
     | 
| 382 | 
         
            +
                                            filtered_df = filtered_df[filtered_df['Model Name'].str.contains(search_query, case=False, na=False)]
         
     | 
| 383 | 
         
            +
                                        
         
     | 
| 384 | 
         
            +
                                        # Apply Precision filter
         
     | 
| 385 | 
         
            +
                                        if precision_filters:
         
     | 
| 386 | 
         
            +
                                            include_missing = 'Missing' in precision_filters
         
     | 
| 387 | 
         
            +
                                            selected_precisions = [p for p in precision_filters if p != 'Missing']
         
     | 
| 388 | 
         
            +
                                            if include_missing:
         
     | 
| 389 | 
         
            +
                                                filtered_df = filtered_df[
         
     | 
| 390 | 
         
            +
                                                    (filtered_df['Precision'].isin(selected_precisions)) |
         
     | 
| 391 | 
         
            +
                                                    (filtered_df['Precision'] == 'UNK') |
         
     | 
| 392 | 
         
            +
                                                    (filtered_df['Precision'].isna())
         
     | 
| 393 | 
         
            +
                                                ]
         
     | 
| 394 | 
         
            +
                                            else:
         
     | 
| 395 | 
         
            +
                                                filtered_df = filtered_df[filtered_df['Precision'].isin(selected_precisions)]
         
     | 
| 396 | 
         
            +
                                        
         
     | 
| 397 | 
         
            +
                                        # Apply License filter
         
     | 
| 398 | 
         
            +
                                        if license_filters:
         
     | 
| 399 | 
         
            +
                                            include_missing = 'Missing' in license_filters
         
     | 
| 400 | 
         
            +
                                            selected_licenses = [l for l in license_filters if l != 'Missing']
         
     | 
| 401 | 
         
            +
                                            if include_missing:
         
     | 
| 402 | 
         
            +
                                                filtered_df = filtered_df[
         
     | 
| 403 | 
         
            +
                                                    (filtered_df['License'].isin(selected_licenses)) |
         
     | 
| 404 | 
         
            +
                                                    (filtered_df['License'] == 'UNK') |
         
     | 
| 405 | 
         
            +
                                                    (filtered_df['License'].isna())
         
     | 
| 406 | 
         
            +
                                                ]
         
     | 
| 407 | 
         
            +
                                            else:
         
     | 
| 408 | 
         
            +
                                                filtered_df = filtered_df[filtered_df['License'].isin(selected_licenses)]
         
     | 
| 409 | 
         
            +
                                        
         
     | 
| 410 | 
         
            +
                                        # Apply Model Size filter
         
     | 
| 411 | 
         
            +
                                        filtered_df = filtered_df[
         
     | 
| 412 | 
         
            +
                                            (filtered_df['Model Size Filter'] >= min_size) &
         
     | 
| 413 | 
         
            +
                                            (filtered_df['Model Size Filter'] <= max_size)
         
     | 
| 414 | 
         
            +
                                        ]
         
     | 
| 415 | 
         
            +
                                        
         
     | 
| 416 | 
         
            +
                                        # Remove existing 'Rank' column if present
         
     | 
| 417 | 
         
            +
                                        if 'Rank' in filtered_df.columns:
         
     | 
| 418 | 
         
            +
                                            filtered_df = filtered_df.drop(columns=['Rank'])
         
     | 
| 419 | 
         
            +
                                        
         
     | 
| 420 | 
         
            +
                                        # Recalculate Rank after filtering
         
     | 
| 421 | 
         
            +
                                        filtered_df = filtered_df.reset_index(drop=True)
         
     | 
| 422 | 
         
            +
                                        filtered_df.insert(0, 'Rank', range(1, len(filtered_df) + 1))
         
     | 
| 423 | 
         
            +
                                        
         
     | 
| 424 | 
         
            +
                                        # Ensure selected columns are present
         
     | 
| 425 | 
         
            +
                                        selected_cols = [col for col in selected_cols if col in filtered_df.columns]
         
     | 
| 426 | 
         
            +
                                        
         
     | 
| 427 | 
         
            +
                                        return filtered_df[selected_cols]
         
     | 
| 428 | 
         
            +
                                    
         
     | 
| 429 | 
         
            +
                                    # Bind the filter function to the appropriate events
         
     | 
| 430 | 
         
            +
                                    filter_inputs_3c3h = [
         
     | 
| 431 | 
         
            +
                                        search_box_retrieval,
         
     | 
| 432 | 
         
            +
                                        precision_filter_retrieval,
         
     | 
| 433 | 
         
            +
                                        license_filter_retrieval,
         
     | 
| 434 | 
         
            +
                                        model_size_min_filter_3c3h,
         
     | 
| 435 | 
         
            +
                                        model_size_max_filter_3c3h
         
     | 
| 436 | 
         
            +
                                    ]
         
     | 
| 437 | 
         
            +
                                    search_box_retrieval.submit(
         
     | 
| 438 | 
         
            +
                                        filter_df_3c3h,
         
     | 
| 439 | 
         
            +
                                        inputs=filter_inputs_3c3h,
         
     | 
| 440 | 
         
            +
                                        outputs=leaderboard_3c3h
         
     | 
| 441 | 
         
            +
                                    )
         
     | 
| 442 | 
         
            +
                                    
         
     | 
| 443 | 
         
            +
                                    # Bind change events for CheckboxGroups and sliders
         
     | 
| 444 | 
         
            +
                                    for component in filter_inputs_3c3h:
         
     | 
| 445 | 
         
            +
                                        component.change(
         
     | 
| 446 | 
         
            +
                                            filter_df_3c3h,
         
     | 
| 447 | 
         
            +
                                            inputs=filter_inputs_3c3h,
         
     | 
| 448 | 
         
            +
                                            outputs=leaderboard_3c3h
         
     | 
| 449 | 
         
            +
                                        )
         
     | 
| 450 | 
         
            +
                                
         
     | 
| 451 | 
         
            +
                                with gr.Tab("Submit Retriever"): 
         
     | 
| 452 | 
         
            +
             
     | 
| 453 | 
         
            +
                                    model_name_input = gr.Textbox(
         
     | 
| 454 | 
         
            +
                                        label="Model", 
         
     | 
| 455 | 
         
            +
                                        placeholder="Enter the full model name from HuggingFace Hub (e.g., inceptionai/jais-family-30b-8k)"
         
     | 
| 456 | 
         
            +
                                    )
         
     | 
| 457 | 
         
            +
                                    revision_input = gr.Textbox(
         
     | 
| 458 | 
         
            +
                                        label="Revision", 
         
     | 
| 459 | 
         
            +
                                        placeholder="main", 
         
     | 
| 460 | 
         
            +
                                        value="main"
         
     | 
| 461 | 
         
            +
                                    )
         
     | 
| 462 | 
         
            +
                                    precision_input = gr.Dropdown(
         
     | 
| 463 | 
         
            +
                                        choices=["float16", "float32", "bfloat16", "8bit", "4bit"], 
         
     | 
| 464 | 
         
            +
                                        label="Precision",
         
     | 
| 465 | 
         
            +
                                        value="float16"
         
     | 
| 466 | 
         
            +
                                    )
         
     | 
| 467 | 
         
            +
                                    params_input = gr.Textbox(
         
     | 
| 468 | 
         
            +
                                        label="Params", 
         
     | 
| 469 | 
         
            +
                                        placeholder="Enter the approximate number of parameters as Integer (e.g., 7, 13, 30, 70 ...)"
         
     | 
| 470 | 
         
            +
                                    )
         
     | 
| 471 | 
         
            +
                                    # Changed from Dropdown to Textbox with default value "Open"
         
     | 
| 472 | 
         
            +
                                    license_input = gr.Textbox(
         
     | 
| 473 | 
         
            +
                                        label="License", 
         
     | 
| 474 | 
         
            +
                                        placeholder="Enter the license type (Generic one is 'Open' in case no License is provided)", 
         
     | 
| 475 | 
         
            +
                                        value="Open"
         
     | 
| 476 | 
         
            +
                                    )
         
     | 
| 477 | 
         
            +
                                    submit_button = gr.Button("Submit Model")
         
     | 
| 478 | 
         
            +
                                    submission_result = gr.Markdown()
         
     | 
| 479 | 
         
            +
             
     | 
| 480 | 
         
            +
                                    submit_button.click(
         
     | 
| 481 | 
         
            +
                                        submit_model,
         
     | 
| 482 | 
         
            +
                                        inputs=[model_name_input, revision_input, precision_input, params_input, license_input],
         
     | 
| 483 | 
         
            +
                                        outputs=submission_result
         
     | 
| 484 | 
         
            +
                                    )
         
     | 
| 485 | 
         
            +
                                    
         
     | 
| 486 | 
         
            +
                                    # Load pending, finished, and failed requests
         
     | 
| 487 | 
         
            +
                                    df_pending = load_requests('pending')
         
     | 
| 488 | 
         
            +
                                    df_finished = load_requests('finished')
         
     | 
| 489 | 
         
            +
                                    df_failed = load_requests('failed')
         
     | 
| 490 | 
         | 
| 491 | 
         
            +
                                    # Display the tables
         
     | 
| 492 | 
         
            +
                                    gr.Markdown("## Evaluation Status")
         
     | 
| 493 | 
         
            +
                                    with gr.Accordion(f"Pending Evaluations ({len(df_pending)})", open=False):
         
     | 
| 494 | 
         
            +
                                        if not df_pending.empty:
         
     | 
| 495 | 
         
            +
                                            gr.Dataframe(df_pending)
         
     | 
| 496 | 
         
            +
                                        else:
         
     | 
| 497 | 
         
            +
                                            gr.Markdown("No pending evaluations.")
         
     | 
| 498 | 
         
            +
                                    with gr.Accordion(f"Finished Evaluations ({len(df_finished)})", open=False):
         
     | 
| 499 | 
         
            +
                                        if not df_finished.empty:
         
     | 
| 500 | 
         
            +
                                            gr.Dataframe(df_finished)
         
     | 
| 501 | 
         
            +
                                        else:
         
     | 
| 502 | 
         
            +
                                            gr.Markdown("No finished evaluations.")
         
     | 
| 503 | 
         
            +
                                    with gr.Accordion(f"Failed Evaluations ({len(df_failed)})", open=False):
         
     | 
| 504 | 
         
            +
                                        if not df_failed.empty:
         
     | 
| 505 | 
         
            +
                                            gr.Dataframe(df_failed)
         
     | 
| 506 | 
         
            +
                                        else:
         
     | 
| 507 | 
         
            +
                                            gr.Markdown("No failed evaluations.")
         
     | 
| 508 | 
         
            +
             
     | 
| 509 | 
         
            +
                        with gr.Tab("Reranking"):
         
     | 
| 510 | 
         
            +
                            with gr.Tabs():
         
     | 
| 511 | 
         
            +
                                with gr.Tab("Leaderboard"):
         
     | 
| 512 | 
         
            +
                                    
         
     | 
| 513 | 
         
             
                                    with gr.Row():
         
     | 
| 514 | 
         
            +
                                        search_box_tasks = gr.Textbox(
         
     | 
| 515 | 
         
            +
                                            placeholder="Search for models...", 
         
     | 
| 516 | 
         
            +
                                            label="Search", 
         
     | 
| 517 | 
         
            +
                                            interactive=True
         
     | 
| 518 | 
         
            +
                                        )
         
     | 
| 519 | 
         
            +
                                    with gr.Row():
         
     | 
| 520 | 
         
            +
                                        column_selector_tasks = gr.CheckboxGroup(
         
     | 
| 521 | 
         
            +
                                            choices=column_choices_tasks,
         
     | 
| 522 | 
         
            +
                                            value=['Rank', 'Model Name'] + task_columns,
         
     | 
| 523 | 
         
            +
                                            label="Select columns to display",
         
     | 
| 524 | 
         
            +
                                        )
         
     | 
| 525 | 
         
            +
                                    with gr.Row():
         
     | 
| 526 | 
         
            +
                                        license_filter_tasks = gr.CheckboxGroup(
         
     | 
| 527 | 
         
            +
                                            choices=license_options_tasks,
         
     | 
| 528 | 
         
            +
                                            value=license_options_tasks.copy(),  # Default all selected
         
     | 
| 529 | 
         
            +
                                            label="Filter by License",
         
     | 
| 530 | 
         
            +
                                        )
         
     | 
| 531 | 
         
            +
                                        precision_filter_tasks = gr.CheckboxGroup(
         
     | 
| 532 | 
         
            +
                                            choices=precision_options_tasks,
         
     | 
| 533 | 
         
            +
                                            value=precision_options_tasks.copy(),  # Default all selected
         
     | 
| 534 | 
         
            +
                                            label="Filter by Precision",
         
     | 
| 535 | 
         
            +
                                        )
         
     | 
| 536 | 
         
            +
                                    with gr.Row():
         
     | 
| 537 | 
         
            +
                                        model_size_min_filter_tasks = gr.Slider(
         
     | 
| 538 | 
         
            +
                                            minimum=min_model_size_tasks,
         
     | 
| 539 | 
         
            +
                                            maximum=max_model_size_tasks,
         
     | 
| 540 | 
         
            +
                                            value=min_model_size_tasks,
         
     | 
| 541 | 
         
            +
                                            step=1,
         
     | 
| 542 | 
         
            +
                                            label="Minimum Model Size",
         
     | 
| 543 | 
         
            +
                                            interactive=True
         
     | 
| 544 | 
         
            +
                                        )
         
     | 
| 545 | 
         
            +
                                        model_size_max_filter_tasks = gr.Slider(
         
     | 
| 546 | 
         
            +
                                            minimum=min_model_size_tasks,
         
     | 
| 547 | 
         
            +
                                            maximum=max_model_size_tasks,
         
     | 
| 548 | 
         
            +
                                            value=max_model_size_tasks,
         
     | 
| 549 | 
         
            +
                                            step=1,
         
     | 
| 550 | 
         
            +
                                            label="Maximum Model Size",
         
     | 
| 551 | 
         
            +
                                            interactive=True
         
     | 
| 552 | 
         
            +
                                        )
         
     | 
| 553 | 
         
            +
                                    
         
     | 
| 554 | 
         
            +
                                    leaderboard_tasks = gr.Dataframe(
         
     | 
| 555 | 
         
            +
                                        df_tasks[['Rank', 'Model Name'] + task_columns],
         
     | 
| 556 | 
         
            +
                                        interactive=False
         
     | 
| 557 | 
         
            +
                                    )
         
     | 
| 558 | 
         
            +
                                    
         
     | 
| 559 | 
         
            +
                                    def filter_df_tasks(search_query, selected_cols, precision_filters, license_filters, min_size, max_size):
         
     | 
| 560 | 
         
            +
                                        filtered_df = df_tasks.copy()
         
     | 
| 561 | 
         
            +
                                        
         
     | 
| 562 | 
         
            +
                                        # Ensure min_size <= max_size
         
     | 
| 563 | 
         
            +
                                        if min_size > max_size:
         
     | 
| 564 | 
         
            +
                                            min_size, max_size = max_size, min_size
         
     | 
| 565 | 
         
            +
                                        
         
     | 
| 566 | 
         
            +
                                        # Apply search filter
         
     | 
| 567 | 
         
            +
                                        if search_query:
         
     | 
| 568 | 
         
            +
                                            filtered_df = filtered_df[filtered_df['Model Name'].str.contains(search_query, case=False, na=False)]
         
     | 
| 569 | 
         
            +
                                        
         
     | 
| 570 | 
         
            +
                                        # Apply Precision filter
         
     | 
| 571 | 
         
            +
                                        if precision_filters:
         
     | 
| 572 | 
         
            +
                                            include_missing = 'Missing' in precision_filters
         
     | 
| 573 | 
         
            +
                                            selected_precisions = [p for p in precision_filters if p != 'Missing']
         
     | 
| 574 | 
         
            +
                                            if include_missing:
         
     | 
| 575 | 
         
            +
                                                filtered_df = filtered_df[
         
     | 
| 576 | 
         
            +
                                                    (filtered_df['Precision'].isin(selected_precisions)) |
         
     | 
| 577 | 
         
            +
                                                    (filtered_df['Precision'] == 'UNK') |
         
     | 
| 578 | 
         
            +
                                                    (filtered_df['Precision'].isna())
         
     | 
| 579 | 
         
            +
                                                ]
         
     | 
| 580 | 
         
            +
                                            else:
         
     | 
| 581 | 
         
            +
                                                filtered_df = filtered_df[filtered_df['Precision'].isin(selected_precisions)]
         
     | 
| 582 | 
         
            +
                                        
         
     | 
| 583 | 
         
            +
                                        # Apply License filter
         
     | 
| 584 | 
         
            +
                                        if license_filters:
         
     | 
| 585 | 
         
            +
                                            include_missing = 'Missing' in license_filters
         
     | 
| 586 | 
         
            +
                                            selected_licenses = [l for l in license_filters if l != 'Missing']
         
     | 
| 587 | 
         
            +
                                            if include_missing:
         
     | 
| 588 | 
         
            +
                                                filtered_df = filtered_df[
         
     | 
| 589 | 
         
            +
                                                    (filtered_df['License'].isin(selected_licenses)) |
         
     | 
| 590 | 
         
            +
                                                    (filtered_df['License'] == 'UNK') |
         
     | 
| 591 | 
         
            +
                                                    (filtered_df['License'].isna())
         
     | 
| 592 | 
         
            +
                                                ]
         
     | 
| 593 | 
         
            +
                                            else:
         
     | 
| 594 | 
         
            +
                                                filtered_df = filtered_df[filtered_df['License'].isin(selected_licenses)]
         
     | 
| 595 | 
         
            +
                                        
         
     | 
| 596 | 
         
            +
                                        # Apply Model Size filter
         
     | 
| 597 | 
         
            +
                                        filtered_df = filtered_df[
         
     | 
| 598 | 
         
            +
                                            (filtered_df['Model Size Filter'] >= min_size) &
         
     | 
| 599 | 
         
            +
                                            (filtered_df['Model Size Filter'] <= max_size)
         
     | 
| 600 | 
         
            +
                                        ]
         
     | 
| 601 | 
         
            +
                                        
         
     | 
| 602 | 
         
            +
                                        # Remove existing 'Rank' column if present
         
     | 
| 603 | 
         
            +
                                        if 'Rank' in filtered_df.columns:
         
     | 
| 604 | 
         
            +
                                            filtered_df = filtered_df.drop(columns=['Rank'])
         
     | 
| 605 | 
         
            +
                                        
         
     | 
| 606 | 
         
            +
                                        # Sort by the first task column if it exists
         
     | 
| 607 | 
         
            +
                                        if task_columns:
         
     | 
| 608 | 
         
            +
                                            first_task = task_columns[0]
         
     | 
| 609 | 
         
            +
                                            filtered_df = filtered_df.sort_values(by=first_task, ascending=False)
         
     | 
| 610 | 
         
            +
                                        else:
         
     | 
| 611 | 
         
            +
                                            filtered_df = filtered_df.sort_values(by='Model Name', ascending=True)
         
     | 
| 612 | 
         
            +
                                        
         
     | 
| 613 | 
         
            +
                                        # Recalculate Rank after filtering
         
     | 
| 614 | 
         
            +
                                        filtered_df = filtered_df.reset_index(drop=True)
         
     | 
| 615 | 
         
            +
                                        filtered_df.insert(0, 'Rank', range(1, len(filtered_df) + 1))
         
     | 
| 616 | 
         
            +
                                        
         
     | 
| 617 | 
         
            +
                                        # Ensure selected columns are present
         
     | 
| 618 | 
         
            +
                                        selected_cols = [col for col in selected_cols if col in filtered_df.columns]
         
     | 
| 619 | 
         
            +
                                        
         
     | 
| 620 | 
         
            +
                                        return filtered_df[selected_cols]
         
     | 
| 621 | 
         
            +
                                    
         
     | 
| 622 | 
         
            +
                                    # Bind the filter function to the appropriate events
         
     | 
| 623 | 
         
            +
                                    filter_inputs_tasks = [
         
     | 
| 624 | 
         
            +
                                        search_box_tasks,
         
     | 
| 625 | 
         
            +
                                        column_selector_tasks,
         
     | 
| 626 | 
         
            +
                                        precision_filter_tasks,
         
     | 
| 627 | 
         
            +
                                        license_filter_tasks,
         
     | 
| 628 | 
         
            +
                                        model_size_min_filter_tasks,
         
     | 
| 629 | 
         
            +
                                        model_size_max_filter_tasks
         
     | 
| 630 | 
         
            +
                                    ]
         
     | 
| 631 | 
         
            +
                                    search_box_tasks.submit(
         
     | 
| 632 | 
         
            +
                                        filter_df_tasks,
         
     | 
| 633 | 
         
            +
                                        inputs=filter_inputs_tasks,
         
     | 
| 634 | 
         
            +
                                        outputs=leaderboard_tasks
         
     | 
| 635 | 
         
            +
                                    )
         
     | 
| 636 | 
         
            +
                                    
         
     | 
| 637 | 
         
            +
                                    # Bind change events for CheckboxGroups and sliders
         
     | 
| 638 | 
         
            +
                                    for component in filter_inputs_tasks:
         
     | 
| 639 | 
         
            +
                                        component.change(
         
     | 
| 640 | 
         
            +
                                            filter_df_tasks,
         
     | 
| 641 | 
         
            +
                                            inputs=filter_inputs_tasks,
         
     | 
| 642 | 
         
            +
                                            outputs=leaderboard_tasks
         
     | 
| 643 | 
         
             
                                        )
         
     | 
| 
         | 
|
| 
         | 
|
| 644 | 
         | 
| 645 | 
         
            +
                                with gr.Tab("Submit Reranker"):
         
     | 
| 646 | 
         
            +
                                    pass
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 647 | 
         | 
| 648 | 
         
            +
                        with gr.Tab("LLM Context Answering"):
         
     | 
| 649 | 
         
            +
                            with gr.Tabs():
         
     | 
| 650 | 
         
            +
                                with gr.Tab("Leaderboard"):
         
     | 
| 651 | 
         
            +
                                    pass
         
     | 
| 652 | 
         
            +
                                with gr.Tab("Submit Here"):
         
     | 
| 653 | 
         
            +
                                    pass
         
     | 
| 654 | 
         
            +
             
     | 
| 655 | 
         
            +
                        with gr.Row():
         
     | 
| 656 | 
         
            +
                            with gr.Accordion("📙 Citation", open=False):
         
     | 
| 657 | 
         
            +
                                citation_button = gr.Textbox(
         
     | 
| 658 | 
         
            +
                                    value=CITATION_BUTTON_TEXT,
         
     | 
| 659 | 
         
            +
                                    label=CITATION_BUTTON_LABEL,
         
     | 
| 660 | 
         
            +
                                    lines=20,
         
     | 
| 661 | 
         
            +
                                    elem_id="citation-button",
         
     | 
| 662 | 
         
            +
                                    show_copy_button=True,
         
     | 
| 663 | 
         
             
                                )
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 664 | 
         | 
| 665 | 
         
            +
                demo.launch()
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 666 | 
         | 
| 667 | 
         
            +
            if __name__ == "__main__":
         
     | 
| 668 | 
         
            +
                main()
         
     | 
| 
         | 
|
| 
         | 
    	
        pyproject.toml
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            [tool.ruff]
         
     | 
| 2 | 
         
            -
            # Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
         
     | 
| 3 | 
         
            -
            select = ["E", "F"]
         
     | 
| 4 | 
         
            -
            ignore = ["E501"] # line too long (black is taking care of this)
         
     | 
| 5 | 
         
            -
            line-length = 119
         
     | 
| 6 | 
         
            -
            fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
         
     | 
| 7 | 
         
            -
             
     | 
| 8 | 
         
            -
            [tool.isort]
         
     | 
| 9 | 
         
            -
            profile = "black"
         
     | 
| 10 | 
         
            -
            line_length = 119
         
     | 
| 11 | 
         
            -
             
     | 
| 12 | 
         
            -
            [tool.black]
         
     | 
| 13 | 
         
            -
            line-length = 119
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        requirements.txt
    DELETED
    
    | 
         @@ -1,16 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            APScheduler
         
     | 
| 2 | 
         
            -
            black
         
     | 
| 3 | 
         
            -
            datasets
         
     | 
| 4 | 
         
            -
            gradio
         
     | 
| 5 | 
         
            -
            gradio[oauth]
         
     | 
| 6 | 
         
            -
            gradio_leaderboard==0.0.13
         
     | 
| 7 | 
         
            -
            gradio_client
         
     | 
| 8 | 
         
            -
            huggingface-hub>=0.18.0
         
     | 
| 9 | 
         
            -
            matplotlib
         
     | 
| 10 | 
         
            -
            numpy
         
     | 
| 11 | 
         
            -
            pandas
         
     | 
| 12 | 
         
            -
            python-dateutil
         
     | 
| 13 | 
         
            -
            tqdm
         
     | 
| 14 | 
         
            -
            transformers
         
     | 
| 15 | 
         
            -
            tokenizers>=0.15.0
         
     | 
| 16 | 
         
            -
            sentencepiece
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/about.py
    DELETED
    
    | 
         @@ -1,72 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            from dataclasses import dataclass
         
     | 
| 2 | 
         
            -
            from enum import Enum
         
     | 
| 3 | 
         
            -
             
     | 
| 4 | 
         
            -
            @dataclass
         
     | 
| 5 | 
         
            -
            class Task:
         
     | 
| 6 | 
         
            -
                benchmark: str
         
     | 
| 7 | 
         
            -
                metric: str
         
     | 
| 8 | 
         
            -
                col_name: str
         
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
            -
             
     | 
| 11 | 
         
            -
            # Select your tasks here
         
     | 
| 12 | 
         
            -
            # ---------------------------------------------------
         
     | 
| 13 | 
         
            -
            class Tasks(Enum):
         
     | 
| 14 | 
         
            -
                # task_key in the json file, metric_key in the json file, name to display in the leaderboard 
         
     | 
| 15 | 
         
            -
                task0 = Task("anli_r1", "acc", "ANLI")
         
     | 
| 16 | 
         
            -
                task1 = Task("logiqa", "acc_norm", "LogiQA")
         
     | 
| 17 | 
         
            -
             
     | 
| 18 | 
         
            -
            NUM_FEWSHOT = 0 # Change with your few shot
         
     | 
| 19 | 
         
            -
            # ---------------------------------------------------
         
     | 
| 20 | 
         
            -
             
     | 
| 21 | 
         
            -
             
     | 
| 22 | 
         
            -
             
     | 
| 23 | 
         
            -
            # Your leaderboard name
         
     | 
| 24 | 
         
            -
            TITLE = """<h1 align="center" id="space-title">The Arabic RAG Leaderboard</h1>"""
         
     | 
| 25 | 
         
            -
             
     | 
| 26 | 
         
            -
            # What does your leaderboard evaluate?
         
     | 
| 27 | 
         
            -
            INTRODUCTION_TEXT = """
         
     | 
| 28 | 
         
            -
            Intro text
         
     | 
| 29 | 
         
            -
            """
         
     | 
| 30 | 
         
            -
             
     | 
| 31 | 
         
            -
            # Which evaluations are you running? how can people reproduce what you have?
         
     | 
| 32 | 
         
            -
            LLM_BENCHMARKS_TEXT = f"""
         
     | 
| 33 | 
         
            -
            ## How it works
         
     | 
| 34 | 
         
            -
             
     | 
| 35 | 
         
            -
            ## Reproducibility
         
     | 
| 36 | 
         
            -
            To reproduce our results, here is the commands you can run:
         
     | 
| 37 | 
         
            -
             
     | 
| 38 | 
         
            -
            """
         
     | 
| 39 | 
         
            -
             
     | 
| 40 | 
         
            -
            EVALUATION_QUEUE_TEXT = """
         
     | 
| 41 | 
         
            -
            ## Some good practices before submitting a model
         
     | 
| 42 | 
         
            -
             
     | 
| 43 | 
         
            -
            ### 1) Make sure you can load your model and tokenizer using AutoClasses:
         
     | 
| 44 | 
         
            -
            ```python
         
     | 
| 45 | 
         
            -
            from transformers import AutoConfig, AutoModel, AutoTokenizer
         
     | 
| 46 | 
         
            -
            config = AutoConfig.from_pretrained("your model name", revision=revision)
         
     | 
| 47 | 
         
            -
            model = AutoModel.from_pretrained("your model name", revision=revision)
         
     | 
| 48 | 
         
            -
            tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
         
     | 
| 49 | 
         
            -
            ```
         
     | 
| 50 | 
         
            -
            If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
         
     | 
| 51 | 
         
            -
             
     | 
| 52 | 
         
            -
            Note: make sure your model is public!
         
     | 
| 53 | 
         
            -
            Note: if your model needs `use_remote_code=True`, we do not support this option yet but we are working on adding it, stay posted!
         
     | 
| 54 | 
         
            -
             
     | 
| 55 | 
         
            -
            ### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
         
     | 
| 56 | 
         
            -
            It's a new format for storing weights which is safer and faster to load and use. It will also allow us to add the number of parameters of your model to the `Extended Viewer`!
         
     | 
| 57 | 
         
            -
             
     | 
| 58 | 
         
            -
            ### 3) Make sure your model has an open license!
         
     | 
| 59 | 
         
            -
            This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
         
     | 
| 60 | 
         
            -
             
     | 
| 61 | 
         
            -
            ### 4) Fill up your model card
         
     | 
| 62 | 
         
            -
            When we add extra information about models to the leaderboard, it will be automatically taken from the model card
         
     | 
| 63 | 
         
            -
             
     | 
| 64 | 
         
            -
            ## In case of model failure
         
     | 
| 65 | 
         
            -
            If your model is displayed in the `FAILED` category, its execution stopped.
         
     | 
| 66 | 
         
            -
            Make sure you have followed the above steps first.
         
     | 
| 67 | 
         
            -
            If everything is done, check you can launch the EleutherAIHarness on your model locally, using the above command without modifications (you can add `--limit` to limit the number of examples per task).
         
     | 
| 68 | 
         
            -
            """
         
     | 
| 69 | 
         
            -
             
     | 
| 70 | 
         
            -
            CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
         
     | 
| 71 | 
         
            -
            CITATION_BUTTON_TEXT = r"""
         
     | 
| 72 | 
         
            -
            """
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/display/css_html_js.py
    DELETED
    
    | 
         @@ -1,105 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            custom_css = """
         
     | 
| 2 | 
         
            -
             
     | 
| 3 | 
         
            -
            .markdown-text {
         
     | 
| 4 | 
         
            -
                font-size: 16px !important;
         
     | 
| 5 | 
         
            -
            }
         
     | 
| 6 | 
         
            -
             
     | 
| 7 | 
         
            -
            #models-to-add-text {
         
     | 
| 8 | 
         
            -
                font-size: 18px !important;
         
     | 
| 9 | 
         
            -
            }
         
     | 
| 10 | 
         
            -
             
     | 
| 11 | 
         
            -
            #citation-button span {
         
     | 
| 12 | 
         
            -
                font-size: 16px !important;
         
     | 
| 13 | 
         
            -
            }
         
     | 
| 14 | 
         
            -
             
     | 
| 15 | 
         
            -
            #citation-button textarea {
         
     | 
| 16 | 
         
            -
                font-size: 16px !important;
         
     | 
| 17 | 
         
            -
            }
         
     | 
| 18 | 
         
            -
             
     | 
| 19 | 
         
            -
            #citation-button > label > button {
         
     | 
| 20 | 
         
            -
                margin: 6px;
         
     | 
| 21 | 
         
            -
                transform: scale(1.3);
         
     | 
| 22 | 
         
            -
            }
         
     | 
| 23 | 
         
            -
             
     | 
| 24 | 
         
            -
            #leaderboard-table {
         
     | 
| 25 | 
         
            -
                margin-top: 15px
         
     | 
| 26 | 
         
            -
            }
         
     | 
| 27 | 
         
            -
             
     | 
| 28 | 
         
            -
            #leaderboard-table-lite {
         
     | 
| 29 | 
         
            -
                margin-top: 15px
         
     | 
| 30 | 
         
            -
            }
         
     | 
| 31 | 
         
            -
             
     | 
| 32 | 
         
            -
            #search-bar-table-box > div:first-child {
         
     | 
| 33 | 
         
            -
                background: none;
         
     | 
| 34 | 
         
            -
                border: none;
         
     | 
| 35 | 
         
            -
            }
         
     | 
| 36 | 
         
            -
             
         
     | 
| 37 | 
         
            -
            #search-bar {
         
     | 
| 38 | 
         
            -
                padding: 0px;
         
     | 
| 39 | 
         
            -
            }
         
     | 
| 40 | 
         
            -
             
     | 
| 41 | 
         
            -
            /* Limit the width of the first AutoEvalColumn so that names don't expand too much */
         
     | 
| 42 | 
         
            -
            #leaderboard-table td:nth-child(2),
         
     | 
| 43 | 
         
            -
            #leaderboard-table th:nth-child(2) {
         
     | 
| 44 | 
         
            -
                max-width: 400px;
         
     | 
| 45 | 
         
            -
                overflow: auto;
         
     | 
| 46 | 
         
            -
                white-space: nowrap;
         
     | 
| 47 | 
         
            -
            }
         
     | 
| 48 | 
         
            -
             
     | 
| 49 | 
         
            -
            .tab-buttons button {
         
     | 
| 50 | 
         
            -
                font-size: 20px;
         
     | 
| 51 | 
         
            -
            }
         
     | 
| 52 | 
         
            -
             
     | 
| 53 | 
         
            -
            #scale-logo {
         
     | 
| 54 | 
         
            -
                border-style: none !important;
         
     | 
| 55 | 
         
            -
                box-shadow: none;
         
     | 
| 56 | 
         
            -
                display: block;
         
     | 
| 57 | 
         
            -
                margin-left: auto;
         
     | 
| 58 | 
         
            -
                margin-right: auto;
         
     | 
| 59 | 
         
            -
                max-width: 600px;
         
     | 
| 60 | 
         
            -
            }
         
     | 
| 61 | 
         
            -
             
     | 
| 62 | 
         
            -
            #scale-logo .download {
         
     | 
| 63 | 
         
            -
                display: none;
         
     | 
| 64 | 
         
            -
            }
         
     | 
| 65 | 
         
            -
            #filter_type{
         
     | 
| 66 | 
         
            -
                border: 0;
         
     | 
| 67 | 
         
            -
                padding-left: 0;
         
     | 
| 68 | 
         
            -
                padding-top: 0;
         
     | 
| 69 | 
         
            -
            }
         
     | 
| 70 | 
         
            -
            #filter_type label {
         
     | 
| 71 | 
         
            -
                display: flex;
         
     | 
| 72 | 
         
            -
            }
         
     | 
| 73 | 
         
            -
            #filter_type label > span{
         
     | 
| 74 | 
         
            -
                margin-top: var(--spacing-lg);
         
     | 
| 75 | 
         
            -
                margin-right: 0.5em;
         
     | 
| 76 | 
         
            -
            }
         
     | 
| 77 | 
         
            -
            #filter_type label > .wrap{
         
     | 
| 78 | 
         
            -
                width: 103px;
         
     | 
| 79 | 
         
            -
            }
         
     | 
| 80 | 
         
            -
            #filter_type label > .wrap .wrap-inner{  
         
     | 
| 81 | 
         
            -
                padding: 2px;
         
     | 
| 82 | 
         
            -
            }
         
     | 
| 83 | 
         
            -
            #filter_type label > .wrap .wrap-inner input{
         
     | 
| 84 | 
         
            -
                width: 1px
         
     | 
| 85 | 
         
            -
            }
         
     | 
| 86 | 
         
            -
            #filter-columns-type{
         
     | 
| 87 | 
         
            -
                border:0;
         
     | 
| 88 | 
         
            -
                padding:0.5;
         
     | 
| 89 | 
         
            -
            }
         
     | 
| 90 | 
         
            -
            #filter-columns-size{
         
     | 
| 91 | 
         
            -
                border:0;
         
     | 
| 92 | 
         
            -
                padding:0.5;
         
     | 
| 93 | 
         
            -
            }
         
     | 
| 94 | 
         
            -
            #box-filter > .form{
         
     | 
| 95 | 
         
            -
                border: 0
         
     | 
| 96 | 
         
            -
            }
         
     | 
| 97 | 
         
            -
            """
         
     | 
| 98 | 
         
            -
             
     | 
| 99 | 
         
            -
            get_window_url_params = """
         
     | 
| 100 | 
         
            -
                function(url_params) {
         
     | 
| 101 | 
         
            -
                    const params = new URLSearchParams(window.location.search);
         
     | 
| 102 | 
         
            -
                    url_params = Object.fromEntries(params);
         
     | 
| 103 | 
         
            -
                    return url_params;
         
     | 
| 104 | 
         
            -
                }
         
     | 
| 105 | 
         
            -
                """
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/display/formatting.py
    DELETED
    
    | 
         @@ -1,27 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            def model_hyperlink(link, model_name):
         
     | 
| 2 | 
         
            -
                return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
         
     | 
| 3 | 
         
            -
             
     | 
| 4 | 
         
            -
             
     | 
| 5 | 
         
            -
            def make_clickable_model(model_name):
         
     | 
| 6 | 
         
            -
                link = f"https://huggingface.co/{model_name}"
         
     | 
| 7 | 
         
            -
                return model_hyperlink(link, model_name)
         
     | 
| 8 | 
         
            -
             
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
            -
            def styled_error(error):
         
     | 
| 11 | 
         
            -
                return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
         
     | 
| 12 | 
         
            -
             
     | 
| 13 | 
         
            -
             
     | 
| 14 | 
         
            -
            def styled_warning(warn):
         
     | 
| 15 | 
         
            -
                return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
         
     | 
| 16 | 
         
            -
             
     | 
| 17 | 
         
            -
             
     | 
| 18 | 
         
            -
            def styled_message(message):
         
     | 
| 19 | 
         
            -
                return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
         
     | 
| 20 | 
         
            -
             
     | 
| 21 | 
         
            -
             
     | 
| 22 | 
         
            -
            def has_no_nan_values(df, columns):
         
     | 
| 23 | 
         
            -
                return df[columns].notna().all(axis=1)
         
     | 
| 24 | 
         
            -
             
     | 
| 25 | 
         
            -
             
     | 
| 26 | 
         
            -
            def has_nan_values(df, columns):
         
     | 
| 27 | 
         
            -
                return df[columns].isna().any(axis=1)
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/display/utils.py
    DELETED
    
    | 
         @@ -1,110 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            from dataclasses import dataclass, make_dataclass
         
     | 
| 2 | 
         
            -
            from enum import Enum
         
     | 
| 3 | 
         
            -
             
     | 
| 4 | 
         
            -
            import pandas as pd
         
     | 
| 5 | 
         
            -
             
     | 
| 6 | 
         
            -
            from src.about import Tasks
         
     | 
| 7 | 
         
            -
             
     | 
| 8 | 
         
            -
            def fields(raw_class):
         
     | 
| 9 | 
         
            -
                return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
         
     | 
| 10 | 
         
            -
             
     | 
| 11 | 
         
            -
             
     | 
| 12 | 
         
            -
            # These classes are for user facing column names,
         
     | 
| 13 | 
         
            -
            # to avoid having to change them all around the code
         
     | 
| 14 | 
         
            -
            # when a modif is needed
         
     | 
| 15 | 
         
            -
            @dataclass
         
     | 
| 16 | 
         
            -
            class ColumnContent:
         
     | 
| 17 | 
         
            -
                name: str
         
     | 
| 18 | 
         
            -
                type: str
         
     | 
| 19 | 
         
            -
                displayed_by_default: bool
         
     | 
| 20 | 
         
            -
                hidden: bool = False
         
     | 
| 21 | 
         
            -
                never_hidden: bool = False
         
     | 
| 22 | 
         
            -
             
     | 
| 23 | 
         
            -
            ## Leaderboard columns
         
     | 
| 24 | 
         
            -
            auto_eval_column_dict = []
         
     | 
| 25 | 
         
            -
            # Init
         
     | 
| 26 | 
         
            -
            auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
         
     | 
| 27 | 
         
            -
            auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
         
     | 
| 28 | 
         
            -
            #Scores
         
     | 
| 29 | 
         
            -
            auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
         
     | 
| 30 | 
         
            -
            for task in Tasks:
         
     | 
| 31 | 
         
            -
                auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
         
     | 
| 32 | 
         
            -
            # Model information
         
     | 
| 33 | 
         
            -
            auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
         
     | 
| 34 | 
         
            -
            auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
         
     | 
| 35 | 
         
            -
            auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
         
     | 
| 36 | 
         
            -
            auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
         
     | 
| 37 | 
         
            -
            auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
         
     | 
| 38 | 
         
            -
            auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
         
     | 
| 39 | 
         
            -
            auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
         
     | 
| 40 | 
         
            -
            auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
         
     | 
| 41 | 
         
            -
            auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
         
     | 
| 42 | 
         
            -
             
     | 
| 43 | 
         
            -
            # We use make dataclass to dynamically fill the scores from Tasks
         
     | 
| 44 | 
         
            -
            AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
         
     | 
| 45 | 
         
            -
             
     | 
| 46 | 
         
            -
            ## For the queue columns in the submission tab
         
     | 
| 47 | 
         
            -
            @dataclass(frozen=True)
         
     | 
| 48 | 
         
            -
            class EvalQueueColumn:  # Queue column
         
     | 
| 49 | 
         
            -
                model = ColumnContent("model", "markdown", True)
         
     | 
| 50 | 
         
            -
                revision = ColumnContent("revision", "str", True)
         
     | 
| 51 | 
         
            -
                private = ColumnContent("private", "bool", True)
         
     | 
| 52 | 
         
            -
                precision = ColumnContent("precision", "str", True)
         
     | 
| 53 | 
         
            -
                weight_type = ColumnContent("weight_type", "str", "Original")
         
     | 
| 54 | 
         
            -
                status = ColumnContent("status", "str", True)
         
     | 
| 55 | 
         
            -
             
     | 
| 56 | 
         
            -
            ## All the model information that we might need
         
     | 
| 57 | 
         
            -
            @dataclass
         
     | 
| 58 | 
         
            -
            class ModelDetails:
         
     | 
| 59 | 
         
            -
                name: str
         
     | 
| 60 | 
         
            -
                display_name: str = ""
         
     | 
| 61 | 
         
            -
                symbol: str = "" # emoji
         
     | 
| 62 | 
         
            -
             
     | 
| 63 | 
         
            -
             
     | 
| 64 | 
         
            -
            class ModelType(Enum):
         
     | 
| 65 | 
         
            -
                PT = ModelDetails(name="pretrained", symbol="🟢")
         
     | 
| 66 | 
         
            -
                FT = ModelDetails(name="fine-tuned", symbol="🔶")
         
     | 
| 67 | 
         
            -
                IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
         
     | 
| 68 | 
         
            -
                RL = ModelDetails(name="RL-tuned", symbol="🟦")
         
     | 
| 69 | 
         
            -
                Unknown = ModelDetails(name="", symbol="?")
         
     | 
| 70 | 
         
            -
             
     | 
| 71 | 
         
            -
                def to_str(self, separator=" "):
         
     | 
| 72 | 
         
            -
                    return f"{self.value.symbol}{separator}{self.value.name}"
         
     | 
| 73 | 
         
            -
             
     | 
| 74 | 
         
            -
                @staticmethod
         
     | 
| 75 | 
         
            -
                def from_str(type):
         
     | 
| 76 | 
         
            -
                    if "fine-tuned" in type or "🔶" in type:
         
     | 
| 77 | 
         
            -
                        return ModelType.FT
         
     | 
| 78 | 
         
            -
                    if "pretrained" in type or "🟢" in type:
         
     | 
| 79 | 
         
            -
                        return ModelType.PT
         
     | 
| 80 | 
         
            -
                    if "RL-tuned" in type or "🟦" in type:
         
     | 
| 81 | 
         
            -
                        return ModelType.RL
         
     | 
| 82 | 
         
            -
                    if "instruction-tuned" in type or "⭕" in type:
         
     | 
| 83 | 
         
            -
                        return ModelType.IFT
         
     | 
| 84 | 
         
            -
                    return ModelType.Unknown
         
     | 
| 85 | 
         
            -
             
     | 
| 86 | 
         
            -
            class WeightType(Enum):
         
     | 
| 87 | 
         
            -
                Adapter = ModelDetails("Adapter")
         
     | 
| 88 | 
         
            -
                Original = ModelDetails("Original")
         
     | 
| 89 | 
         
            -
                Delta = ModelDetails("Delta")
         
     | 
| 90 | 
         
            -
             
     | 
| 91 | 
         
            -
            class Precision(Enum):
         
     | 
| 92 | 
         
            -
                float16 = ModelDetails("float16")
         
     | 
| 93 | 
         
            -
                bfloat16 = ModelDetails("bfloat16")
         
     | 
| 94 | 
         
            -
                Unknown = ModelDetails("?")
         
     | 
| 95 | 
         
            -
             
     | 
| 96 | 
         
            -
                def from_str(precision):
         
     | 
| 97 | 
         
            -
                    if precision in ["torch.float16", "float16"]:
         
     | 
| 98 | 
         
            -
                        return Precision.float16
         
     | 
| 99 | 
         
            -
                    if precision in ["torch.bfloat16", "bfloat16"]:
         
     | 
| 100 | 
         
            -
                        return Precision.bfloat16
         
     | 
| 101 | 
         
            -
                    return Precision.Unknown
         
     | 
| 102 | 
         
            -
             
     | 
| 103 | 
         
            -
            # Column selection
         
     | 
| 104 | 
         
            -
            COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
         
     | 
| 105 | 
         
            -
             
     | 
| 106 | 
         
            -
            EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
         
     | 
| 107 | 
         
            -
            EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
         
     | 
| 108 | 
         
            -
             
     | 
| 109 | 
         
            -
            BENCHMARK_COLS = [t.value.col_name for t in Tasks]
         
     | 
| 110 | 
         
            -
             
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/envs.py
    DELETED
    
    | 
         @@ -1,25 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            import os
         
     | 
| 2 | 
         
            -
             
     | 
| 3 | 
         
            -
            from huggingface_hub import HfApi
         
     | 
| 4 | 
         
            -
             
     | 
| 5 | 
         
            -
            # Info to change for your repository
         
     | 
| 6 | 
         
            -
            # ----------------------------------
         
     | 
| 7 | 
         
            -
            TOKEN = os.environ.get("HF_TOKEN") # A read/write token for your org
         
     | 
| 8 | 
         
            -
             
     | 
| 9 | 
         
            -
            OWNER = "demo-leaderboard-backend" # Change to your org - don't forget to create a results and request dataset, with the correct format!
         
     | 
| 10 | 
         
            -
            # ----------------------------------
         
     | 
| 11 | 
         
            -
             
     | 
| 12 | 
         
            -
            REPO_ID = f"{OWNER}/leaderboard"
         
     | 
| 13 | 
         
            -
            QUEUE_REPO = f"{OWNER}/requests"
         
     | 
| 14 | 
         
            -
            RESULTS_REPO = f"{OWNER}/results"
         
     | 
| 15 | 
         
            -
             
     | 
| 16 | 
         
            -
            # If you setup a cache later, just change HF_HOME
         
     | 
| 17 | 
         
            -
            CACHE_PATH=os.getenv("HF_HOME", ".")
         
     | 
| 18 | 
         
            -
             
     | 
| 19 | 
         
            -
            # Local caches
         
     | 
| 20 | 
         
            -
            EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
         
     | 
| 21 | 
         
            -
            EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
         
     | 
| 22 | 
         
            -
            EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
         
     | 
| 23 | 
         
            -
            EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
         
     | 
| 24 | 
         
            -
             
     | 
| 25 | 
         
            -
            API = HfApi(token=TOKEN)
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/leaderboard/read_evals.py
    DELETED
    
    | 
         @@ -1,196 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            import glob
         
     | 
| 2 | 
         
            -
            import json
         
     | 
| 3 | 
         
            -
            import math
         
     | 
| 4 | 
         
            -
            import os
         
     | 
| 5 | 
         
            -
            from dataclasses import dataclass
         
     | 
| 6 | 
         
            -
             
     | 
| 7 | 
         
            -
            import dateutil
         
     | 
| 8 | 
         
            -
            import numpy as np
         
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
            -
            from src.display.formatting import make_clickable_model
         
     | 
| 11 | 
         
            -
            from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
         
     | 
| 12 | 
         
            -
            from src.submission.check_validity import is_model_on_hub
         
     | 
| 13 | 
         
            -
             
     | 
| 14 | 
         
            -
             
     | 
| 15 | 
         
            -
            @dataclass
         
     | 
| 16 | 
         
            -
            class EvalResult:
         
     | 
| 17 | 
         
            -
                """Represents one full evaluation. Built from a combination of the result and request file for a given run.
         
     | 
| 18 | 
         
            -
                """
         
     | 
| 19 | 
         
            -
                eval_name: str # org_model_precision (uid)
         
     | 
| 20 | 
         
            -
                full_model: str # org/model (path on hub)
         
     | 
| 21 | 
         
            -
                org: str 
         
     | 
| 22 | 
         
            -
                model: str
         
     | 
| 23 | 
         
            -
                revision: str # commit hash, "" if main
         
     | 
| 24 | 
         
            -
                results: dict
         
     | 
| 25 | 
         
            -
                precision: Precision = Precision.Unknown
         
     | 
| 26 | 
         
            -
                model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
         
     | 
| 27 | 
         
            -
                weight_type: WeightType = WeightType.Original # Original or Adapter
         
     | 
| 28 | 
         
            -
                architecture: str = "Unknown" 
         
     | 
| 29 | 
         
            -
                license: str = "?"
         
     | 
| 30 | 
         
            -
                likes: int = 0
         
     | 
| 31 | 
         
            -
                num_params: int = 0
         
     | 
| 32 | 
         
            -
                date: str = "" # submission date of request file
         
     | 
| 33 | 
         
            -
                still_on_hub: bool = False
         
     | 
| 34 | 
         
            -
             
     | 
| 35 | 
         
            -
                @classmethod
         
     | 
| 36 | 
         
            -
                def init_from_json_file(self, json_filepath):
         
     | 
| 37 | 
         
            -
                    """Inits the result from the specific model result file"""
         
     | 
| 38 | 
         
            -
                    with open(json_filepath) as fp:
         
     | 
| 39 | 
         
            -
                        data = json.load(fp)
         
     | 
| 40 | 
         
            -
             
     | 
| 41 | 
         
            -
                    config = data.get("config")
         
     | 
| 42 | 
         
            -
             
     | 
| 43 | 
         
            -
                    # Precision
         
     | 
| 44 | 
         
            -
                    precision = Precision.from_str(config.get("model_dtype"))
         
     | 
| 45 | 
         
            -
             
     | 
| 46 | 
         
            -
                    # Get model and org
         
     | 
| 47 | 
         
            -
                    org_and_model = config.get("model_name", config.get("model_args", None))
         
     | 
| 48 | 
         
            -
                    org_and_model = org_and_model.split("/", 1)
         
     | 
| 49 | 
         
            -
             
     | 
| 50 | 
         
            -
                    if len(org_and_model) == 1:
         
     | 
| 51 | 
         
            -
                        org = None
         
     | 
| 52 | 
         
            -
                        model = org_and_model[0]
         
     | 
| 53 | 
         
            -
                        result_key = f"{model}_{precision.value.name}"
         
     | 
| 54 | 
         
            -
                    else:
         
     | 
| 55 | 
         
            -
                        org = org_and_model[0]
         
     | 
| 56 | 
         
            -
                        model = org_and_model[1]
         
     | 
| 57 | 
         
            -
                        result_key = f"{org}_{model}_{precision.value.name}"
         
     | 
| 58 | 
         
            -
                    full_model = "/".join(org_and_model)
         
     | 
| 59 | 
         
            -
             
     | 
| 60 | 
         
            -
                    still_on_hub, _, model_config = is_model_on_hub(
         
     | 
| 61 | 
         
            -
                        full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
         
     | 
| 62 | 
         
            -
                    )
         
     | 
| 63 | 
         
            -
                    architecture = "?"
         
     | 
| 64 | 
         
            -
                    if model_config is not None:
         
     | 
| 65 | 
         
            -
                        architectures = getattr(model_config, "architectures", None)
         
     | 
| 66 | 
         
            -
                        if architectures:
         
     | 
| 67 | 
         
            -
                            architecture = ";".join(architectures)
         
     | 
| 68 | 
         
            -
             
     | 
| 69 | 
         
            -
                    # Extract results available in this file (some results are split in several files)
         
     | 
| 70 | 
         
            -
                    results = {}
         
     | 
| 71 | 
         
            -
                    for task in Tasks:
         
     | 
| 72 | 
         
            -
                        task = task.value
         
     | 
| 73 | 
         
            -
             
     | 
| 74 | 
         
            -
                        # We average all scores of a given metric (not all metrics are present in all files)
         
     | 
| 75 | 
         
            -
                        accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
         
     | 
| 76 | 
         
            -
                        if accs.size == 0 or any([acc is None for acc in accs]):
         
     | 
| 77 | 
         
            -
                            continue
         
     | 
| 78 | 
         
            -
             
     | 
| 79 | 
         
            -
                        mean_acc = np.mean(accs) * 100.0
         
     | 
| 80 | 
         
            -
                        results[task.benchmark] = mean_acc
         
     | 
| 81 | 
         
            -
             
     | 
| 82 | 
         
            -
                    return self(
         
     | 
| 83 | 
         
            -
                        eval_name=result_key,
         
     | 
| 84 | 
         
            -
                        full_model=full_model,
         
     | 
| 85 | 
         
            -
                        org=org,
         
     | 
| 86 | 
         
            -
                        model=model,
         
     | 
| 87 | 
         
            -
                        results=results,
         
     | 
| 88 | 
         
            -
                        precision=precision,  
         
     | 
| 89 | 
         
            -
                        revision= config.get("model_sha", ""),
         
     | 
| 90 | 
         
            -
                        still_on_hub=still_on_hub,
         
     | 
| 91 | 
         
            -
                        architecture=architecture
         
     | 
| 92 | 
         
            -
                    )
         
     | 
| 93 | 
         
            -
             
     | 
| 94 | 
         
            -
                def update_with_request_file(self, requests_path):
         
     | 
| 95 | 
         
            -
                    """Finds the relevant request file for the current model and updates info with it"""
         
     | 
| 96 | 
         
            -
                    request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
         
     | 
| 97 | 
         
            -
             
     | 
| 98 | 
         
            -
                    try:
         
     | 
| 99 | 
         
            -
                        with open(request_file, "r") as f:
         
     | 
| 100 | 
         
            -
                            request = json.load(f)
         
     | 
| 101 | 
         
            -
                        self.model_type = ModelType.from_str(request.get("model_type", ""))
         
     | 
| 102 | 
         
            -
                        self.weight_type = WeightType[request.get("weight_type", "Original")]
         
     | 
| 103 | 
         
            -
                        self.license = request.get("license", "?")
         
     | 
| 104 | 
         
            -
                        self.likes = request.get("likes", 0)
         
     | 
| 105 | 
         
            -
                        self.num_params = request.get("params", 0)
         
     | 
| 106 | 
         
            -
                        self.date = request.get("submitted_time", "")
         
     | 
| 107 | 
         
            -
                    except Exception:
         
     | 
| 108 | 
         
            -
                        print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
         
     | 
| 109 | 
         
            -
             
     | 
| 110 | 
         
            -
                def to_dict(self):
         
     | 
| 111 | 
         
            -
                    """Converts the Eval Result to a dict compatible with our dataframe display"""
         
     | 
| 112 | 
         
            -
                    average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
         
     | 
| 113 | 
         
            -
                    data_dict = {
         
     | 
| 114 | 
         
            -
                        "eval_name": self.eval_name,  # not a column, just a save name,
         
     | 
| 115 | 
         
            -
                        AutoEvalColumn.precision.name: self.precision.value.name,
         
     | 
| 116 | 
         
            -
                        AutoEvalColumn.model_type.name: self.model_type.value.name,
         
     | 
| 117 | 
         
            -
                        AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
         
     | 
| 118 | 
         
            -
                        AutoEvalColumn.weight_type.name: self.weight_type.value.name,
         
     | 
| 119 | 
         
            -
                        AutoEvalColumn.architecture.name: self.architecture,
         
     | 
| 120 | 
         
            -
                        AutoEvalColumn.model.name: make_clickable_model(self.full_model),
         
     | 
| 121 | 
         
            -
                        AutoEvalColumn.revision.name: self.revision,
         
     | 
| 122 | 
         
            -
                        AutoEvalColumn.average.name: average,
         
     | 
| 123 | 
         
            -
                        AutoEvalColumn.license.name: self.license,
         
     | 
| 124 | 
         
            -
                        AutoEvalColumn.likes.name: self.likes,
         
     | 
| 125 | 
         
            -
                        AutoEvalColumn.params.name: self.num_params,
         
     | 
| 126 | 
         
            -
                        AutoEvalColumn.still_on_hub.name: self.still_on_hub,
         
     | 
| 127 | 
         
            -
                    }
         
     | 
| 128 | 
         
            -
             
     | 
| 129 | 
         
            -
                    for task in Tasks:
         
     | 
| 130 | 
         
            -
                        data_dict[task.value.col_name] = self.results[task.value.benchmark]
         
     | 
| 131 | 
         
            -
             
     | 
| 132 | 
         
            -
                    return data_dict
         
     | 
| 133 | 
         
            -
             
     | 
| 134 | 
         
            -
             
     | 
| 135 | 
         
            -
            def get_request_file_for_model(requests_path, model_name, precision):
         
     | 
| 136 | 
         
            -
                """Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
         
     | 
| 137 | 
         
            -
                request_files = os.path.join(
         
     | 
| 138 | 
         
            -
                    requests_path,
         
     | 
| 139 | 
         
            -
                    f"{model_name}_eval_request_*.json",
         
     | 
| 140 | 
         
            -
                )
         
     | 
| 141 | 
         
            -
                request_files = glob.glob(request_files)
         
     | 
| 142 | 
         
            -
             
     | 
| 143 | 
         
            -
                # Select correct request file (precision)
         
     | 
| 144 | 
         
            -
                request_file = ""
         
     | 
| 145 | 
         
            -
                request_files = sorted(request_files, reverse=True)
         
     | 
| 146 | 
         
            -
                for tmp_request_file in request_files:
         
     | 
| 147 | 
         
            -
                    with open(tmp_request_file, "r") as f:
         
     | 
| 148 | 
         
            -
                        req_content = json.load(f)
         
     | 
| 149 | 
         
            -
                        if (
         
     | 
| 150 | 
         
            -
                            req_content["status"] in ["FINISHED"]
         
     | 
| 151 | 
         
            -
                            and req_content["precision"] == precision.split(".")[-1]
         
     | 
| 152 | 
         
            -
                        ):
         
     | 
| 153 | 
         
            -
                            request_file = tmp_request_file
         
     | 
| 154 | 
         
            -
                return request_file
         
     | 
| 155 | 
         
            -
             
     | 
| 156 | 
         
            -
             
     | 
| 157 | 
         
            -
            def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
         
     | 
| 158 | 
         
            -
                """From the path of the results folder root, extract all needed info for results"""
         
     | 
| 159 | 
         
            -
                model_result_filepaths = []
         
     | 
| 160 | 
         
            -
             
     | 
| 161 | 
         
            -
                for root, _, files in os.walk(results_path):
         
     | 
| 162 | 
         
            -
                    # We should only have json files in model results
         
     | 
| 163 | 
         
            -
                    if len(files) == 0 or any([not f.endswith(".json") for f in files]):
         
     | 
| 164 | 
         
            -
                        continue
         
     | 
| 165 | 
         
            -
             
     | 
| 166 | 
         
            -
                    # Sort the files by date
         
     | 
| 167 | 
         
            -
                    try:
         
     | 
| 168 | 
         
            -
                        files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
         
     | 
| 169 | 
         
            -
                    except dateutil.parser._parser.ParserError:
         
     | 
| 170 | 
         
            -
                        files = [files[-1]]
         
     | 
| 171 | 
         
            -
             
     | 
| 172 | 
         
            -
                    for file in files:
         
     | 
| 173 | 
         
            -
                        model_result_filepaths.append(os.path.join(root, file))
         
     | 
| 174 | 
         
            -
             
     | 
| 175 | 
         
            -
                eval_results = {}
         
     | 
| 176 | 
         
            -
                for model_result_filepath in model_result_filepaths:
         
     | 
| 177 | 
         
            -
                    # Creation of result
         
     | 
| 178 | 
         
            -
                    eval_result = EvalResult.init_from_json_file(model_result_filepath)
         
     | 
| 179 | 
         
            -
                    eval_result.update_with_request_file(requests_path)
         
     | 
| 180 | 
         
            -
             
     | 
| 181 | 
         
            -
                    # Store results of same eval together
         
     | 
| 182 | 
         
            -
                    eval_name = eval_result.eval_name
         
     | 
| 183 | 
         
            -
                    if eval_name in eval_results.keys():
         
     | 
| 184 | 
         
            -
                        eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
         
     | 
| 185 | 
         
            -
                    else:
         
     | 
| 186 | 
         
            -
                        eval_results[eval_name] = eval_result
         
     | 
| 187 | 
         
            -
             
     | 
| 188 | 
         
            -
                results = []
         
     | 
| 189 | 
         
            -
                for v in eval_results.values():
         
     | 
| 190 | 
         
            -
                    try:
         
     | 
| 191 | 
         
            -
                        v.to_dict() # we test if the dict version is complete
         
     | 
| 192 | 
         
            -
                        results.append(v)
         
     | 
| 193 | 
         
            -
                    except KeyError:  # not all eval values present
         
     | 
| 194 | 
         
            -
                        continue
         
     | 
| 195 | 
         
            -
             
     | 
| 196 | 
         
            -
                return results
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/populate.py
    DELETED
    
    | 
         @@ -1,58 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            import json
         
     | 
| 2 | 
         
            -
            import os
         
     | 
| 3 | 
         
            -
             
     | 
| 4 | 
         
            -
            import pandas as pd
         
     | 
| 5 | 
         
            -
             
     | 
| 6 | 
         
            -
            from src.display.formatting import has_no_nan_values, make_clickable_model
         
     | 
| 7 | 
         
            -
            from src.display.utils import AutoEvalColumn, EvalQueueColumn
         
     | 
| 8 | 
         
            -
            from src.leaderboard.read_evals import get_raw_eval_results
         
     | 
| 9 | 
         
            -
             
     | 
| 10 | 
         
            -
             
     | 
| 11 | 
         
            -
            def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
         
     | 
| 12 | 
         
            -
                """Creates a dataframe from all the individual experiment results"""
         
     | 
| 13 | 
         
            -
                raw_data = get_raw_eval_results(results_path, requests_path)
         
     | 
| 14 | 
         
            -
                all_data_json = [v.to_dict() for v in raw_data]
         
     | 
| 15 | 
         
            -
             
     | 
| 16 | 
         
            -
                df = pd.DataFrame.from_records(all_data_json)
         
     | 
| 17 | 
         
            -
                df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
         
     | 
| 18 | 
         
            -
                df = df[cols].round(decimals=2)
         
     | 
| 19 | 
         
            -
             
     | 
| 20 | 
         
            -
                # filter out if any of the benchmarks have not been produced
         
     | 
| 21 | 
         
            -
                df = df[has_no_nan_values(df, benchmark_cols)]
         
     | 
| 22 | 
         
            -
                return df
         
     | 
| 23 | 
         
            -
             
     | 
| 24 | 
         
            -
             
     | 
| 25 | 
         
            -
            def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
         
     | 
| 26 | 
         
            -
                """Creates the different dataframes for the evaluation queues requestes"""
         
     | 
| 27 | 
         
            -
                entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
         
     | 
| 28 | 
         
            -
                all_evals = []
         
     | 
| 29 | 
         
            -
             
     | 
| 30 | 
         
            -
                for entry in entries:
         
     | 
| 31 | 
         
            -
                    if ".json" in entry:
         
     | 
| 32 | 
         
            -
                        file_path = os.path.join(save_path, entry)
         
     | 
| 33 | 
         
            -
                        with open(file_path) as fp:
         
     | 
| 34 | 
         
            -
                            data = json.load(fp)
         
     | 
| 35 | 
         
            -
             
     | 
| 36 | 
         
            -
                        data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
         
     | 
| 37 | 
         
            -
                        data[EvalQueueColumn.revision.name] = data.get("revision", "main")
         
     | 
| 38 | 
         
            -
             
     | 
| 39 | 
         
            -
                        all_evals.append(data)
         
     | 
| 40 | 
         
            -
                    elif ".md" not in entry:
         
     | 
| 41 | 
         
            -
                        # this is a folder
         
     | 
| 42 | 
         
            -
                        sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
         
     | 
| 43 | 
         
            -
                        for sub_entry in sub_entries:
         
     | 
| 44 | 
         
            -
                            file_path = os.path.join(save_path, entry, sub_entry)
         
     | 
| 45 | 
         
            -
                            with open(file_path) as fp:
         
     | 
| 46 | 
         
            -
                                data = json.load(fp)
         
     | 
| 47 | 
         
            -
             
     | 
| 48 | 
         
            -
                            data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
         
     | 
| 49 | 
         
            -
                            data[EvalQueueColumn.revision.name] = data.get("revision", "main")
         
     | 
| 50 | 
         
            -
                            all_evals.append(data)
         
     | 
| 51 | 
         
            -
             
     | 
| 52 | 
         
            -
                pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
         
     | 
| 53 | 
         
            -
                running_list = [e for e in all_evals if e["status"] == "RUNNING"]
         
     | 
| 54 | 
         
            -
                finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
         
     | 
| 55 | 
         
            -
                df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
         
     | 
| 56 | 
         
            -
                df_running = pd.DataFrame.from_records(running_list, columns=cols)
         
     | 
| 57 | 
         
            -
                df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
         
     | 
| 58 | 
         
            -
                return df_finished[cols], df_running[cols], df_pending[cols]
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/submission/check_validity.py
    DELETED
    
    | 
         @@ -1,99 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            import json
         
     | 
| 2 | 
         
            -
            import os
         
     | 
| 3 | 
         
            -
            import re
         
     | 
| 4 | 
         
            -
            from collections import defaultdict
         
     | 
| 5 | 
         
            -
            from datetime import datetime, timedelta, timezone
         
     | 
| 6 | 
         
            -
             
     | 
| 7 | 
         
            -
            import huggingface_hub
         
     | 
| 8 | 
         
            -
            from huggingface_hub import ModelCard
         
     | 
| 9 | 
         
            -
            from huggingface_hub.hf_api import ModelInfo
         
     | 
| 10 | 
         
            -
            from transformers import AutoConfig
         
     | 
| 11 | 
         
            -
            from transformers.models.auto.tokenization_auto import AutoTokenizer
         
     | 
| 12 | 
         
            -
             
     | 
| 13 | 
         
            -
            def check_model_card(repo_id: str) -> tuple[bool, str]:
         
     | 
| 14 | 
         
            -
                """Checks if the model card and license exist and have been filled"""
         
     | 
| 15 | 
         
            -
                try:
         
     | 
| 16 | 
         
            -
                    card = ModelCard.load(repo_id)
         
     | 
| 17 | 
         
            -
                except huggingface_hub.utils.EntryNotFoundError:
         
     | 
| 18 | 
         
            -
                    return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
         
     | 
| 19 | 
         
            -
             
     | 
| 20 | 
         
            -
                # Enforce license metadata
         
     | 
| 21 | 
         
            -
                if card.data.license is None:
         
     | 
| 22 | 
         
            -
                    if not ("license_name" in card.data and "license_link" in card.data):
         
     | 
| 23 | 
         
            -
                        return False, (
         
     | 
| 24 | 
         
            -
                            "License not found. Please add a license to your model card using the `license` metadata or a"
         
     | 
| 25 | 
         
            -
                            " `license_name`/`license_link` pair."
         
     | 
| 26 | 
         
            -
                        )
         
     | 
| 27 | 
         
            -
             
     | 
| 28 | 
         
            -
                # Enforce card content
         
     | 
| 29 | 
         
            -
                if len(card.text) < 200:
         
     | 
| 30 | 
         
            -
                    return False, "Please add a description to your model card, it is too short."
         
     | 
| 31 | 
         
            -
             
     | 
| 32 | 
         
            -
                return True, ""
         
     | 
| 33 | 
         
            -
             
     | 
| 34 | 
         
            -
            def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
         
     | 
| 35 | 
         
            -
                """Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
         
     | 
| 36 | 
         
            -
                try:
         
     | 
| 37 | 
         
            -
                    config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
         
     | 
| 38 | 
         
            -
                    if test_tokenizer:
         
     | 
| 39 | 
         
            -
                        try:
         
     | 
| 40 | 
         
            -
                            tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
         
     | 
| 41 | 
         
            -
                        except ValueError as e:
         
     | 
| 42 | 
         
            -
                            return (
         
     | 
| 43 | 
         
            -
                                False,
         
     | 
| 44 | 
         
            -
                                f"uses a tokenizer which is not in a transformers release: {e}",
         
     | 
| 45 | 
         
            -
                                None
         
     | 
| 46 | 
         
            -
                            )
         
     | 
| 47 | 
         
            -
                        except Exception as e:
         
     | 
| 48 | 
         
            -
                            return (False, "'s tokenizer cannot be loaded. Is your tokenizer class in a stable transformers release, and correctly configured?", None)
         
     | 
| 49 | 
         
            -
                    return True, None, config
         
     | 
| 50 | 
         
            -
             
     | 
| 51 | 
         
            -
                except ValueError:
         
     | 
| 52 | 
         
            -
                    return (
         
     | 
| 53 | 
         
            -
                        False,
         
     | 
| 54 | 
         
            -
                        "needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",
         
     | 
| 55 | 
         
            -
                        None
         
     | 
| 56 | 
         
            -
                    )
         
     | 
| 57 | 
         
            -
             
     | 
| 58 | 
         
            -
                except Exception as e:
         
     | 
| 59 | 
         
            -
                    return False, "was not found on hub!", None
         
     | 
| 60 | 
         
            -
             
     | 
| 61 | 
         
            -
             
     | 
| 62 | 
         
            -
            def get_model_size(model_info: ModelInfo, precision: str):
         
     | 
| 63 | 
         
            -
                """Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
         
     | 
| 64 | 
         
            -
                try:
         
     | 
| 65 | 
         
            -
                    model_size = round(model_info.safetensors["total"] / 1e9, 3)
         
     | 
| 66 | 
         
            -
                except (AttributeError, TypeError):
         
     | 
| 67 | 
         
            -
                    return 0  # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
         
     | 
| 68 | 
         
            -
             
     | 
| 69 | 
         
            -
                size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
         
     | 
| 70 | 
         
            -
                model_size = size_factor * model_size
         
     | 
| 71 | 
         
            -
                return model_size
         
     | 
| 72 | 
         
            -
             
     | 
| 73 | 
         
            -
            def get_model_arch(model_info: ModelInfo):
         
     | 
| 74 | 
         
            -
                """Gets the model architecture from the configuration"""
         
     | 
| 75 | 
         
            -
                return model_info.config.get("architectures", "Unknown")
         
     | 
| 76 | 
         
            -
             
     | 
| 77 | 
         
            -
            def already_submitted_models(requested_models_dir: str) -> set[str]:
         
     | 
| 78 | 
         
            -
                """Gather a list of already submitted models to avoid duplicates"""
         
     | 
| 79 | 
         
            -
                depth = 1
         
     | 
| 80 | 
         
            -
                file_names = []
         
     | 
| 81 | 
         
            -
                users_to_submission_dates = defaultdict(list)
         
     | 
| 82 | 
         
            -
             
     | 
| 83 | 
         
            -
                for root, _, files in os.walk(requested_models_dir):
         
     | 
| 84 | 
         
            -
                    current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
         
     | 
| 85 | 
         
            -
                    if current_depth == depth:
         
     | 
| 86 | 
         
            -
                        for file in files:
         
     | 
| 87 | 
         
            -
                            if not file.endswith(".json"):
         
     | 
| 88 | 
         
            -
                                continue
         
     | 
| 89 | 
         
            -
                            with open(os.path.join(root, file), "r") as f:
         
     | 
| 90 | 
         
            -
                                info = json.load(f)
         
     | 
| 91 | 
         
            -
                                file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
         
     | 
| 92 | 
         
            -
             
     | 
| 93 | 
         
            -
                                # Select organisation
         
     | 
| 94 | 
         
            -
                                if info["model"].count("/") == 0 or "submitted_time" not in info:
         
     | 
| 95 | 
         
            -
                                    continue
         
     | 
| 96 | 
         
            -
                                organisation, _ = info["model"].split("/")
         
     | 
| 97 | 
         
            -
                                users_to_submission_dates[organisation].append(info["submitted_time"])
         
     | 
| 98 | 
         
            -
             
     | 
| 99 | 
         
            -
                return set(file_names), users_to_submission_dates
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
    	
        src/submission/submit.py
    DELETED
    
    | 
         @@ -1,119 +0,0 @@ 
     | 
|
| 1 | 
         
            -
            import json
         
     | 
| 2 | 
         
            -
            import os
         
     | 
| 3 | 
         
            -
            from datetime import datetime, timezone
         
     | 
| 4 | 
         
            -
             
     | 
| 5 | 
         
            -
            from src.display.formatting import styled_error, styled_message, styled_warning
         
     | 
| 6 | 
         
            -
            from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
         
     | 
| 7 | 
         
            -
            from src.submission.check_validity import (
         
     | 
| 8 | 
         
            -
                already_submitted_models,
         
     | 
| 9 | 
         
            -
                check_model_card,
         
     | 
| 10 | 
         
            -
                get_model_size,
         
     | 
| 11 | 
         
            -
                is_model_on_hub,
         
     | 
| 12 | 
         
            -
            )
         
     | 
| 13 | 
         
            -
             
     | 
| 14 | 
         
            -
            REQUESTED_MODELS = None
         
     | 
| 15 | 
         
            -
            USERS_TO_SUBMISSION_DATES = None
         
     | 
| 16 | 
         
            -
             
     | 
| 17 | 
         
            -
            def add_new_eval(
         
     | 
| 18 | 
         
            -
                model: str,
         
     | 
| 19 | 
         
            -
                base_model: str,
         
     | 
| 20 | 
         
            -
                revision: str,
         
     | 
| 21 | 
         
            -
                precision: str,
         
     | 
| 22 | 
         
            -
                weight_type: str,
         
     | 
| 23 | 
         
            -
                model_type: str,
         
     | 
| 24 | 
         
            -
            ):
         
     | 
| 25 | 
         
            -
                global REQUESTED_MODELS
         
     | 
| 26 | 
         
            -
                global USERS_TO_SUBMISSION_DATES
         
     | 
| 27 | 
         
            -
                if not REQUESTED_MODELS:
         
     | 
| 28 | 
         
            -
                    REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
         
     | 
| 29 | 
         
            -
             
     | 
| 30 | 
         
            -
                user_name = ""
         
     | 
| 31 | 
         
            -
                model_path = model
         
     | 
| 32 | 
         
            -
                if "/" in model:
         
     | 
| 33 | 
         
            -
                    user_name = model.split("/")[0]
         
     | 
| 34 | 
         
            -
                    model_path = model.split("/")[1]
         
     | 
| 35 | 
         
            -
             
     | 
| 36 | 
         
            -
                precision = precision.split(" ")[0]
         
     | 
| 37 | 
         
            -
                current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
         
     | 
| 38 | 
         
            -
             
     | 
| 39 | 
         
            -
                if model_type is None or model_type == "":
         
     | 
| 40 | 
         
            -
                    return styled_error("Please select a model type.")
         
     | 
| 41 | 
         
            -
             
     | 
| 42 | 
         
            -
                # Does the model actually exist?
         
     | 
| 43 | 
         
            -
                if revision == "":
         
     | 
| 44 | 
         
            -
                    revision = "main"
         
     | 
| 45 | 
         
            -
             
     | 
| 46 | 
         
            -
                # Is the model on the hub?
         
     | 
| 47 | 
         
            -
                if weight_type in ["Delta", "Adapter"]:
         
     | 
| 48 | 
         
            -
                    base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=True)
         
     | 
| 49 | 
         
            -
                    if not base_model_on_hub:
         
     | 
| 50 | 
         
            -
                        return styled_error(f'Base model "{base_model}" {error}')
         
     | 
| 51 | 
         
            -
             
     | 
| 52 | 
         
            -
                if not weight_type == "Adapter":
         
     | 
| 53 | 
         
            -
                    model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=True)
         
     | 
| 54 | 
         
            -
                    if not model_on_hub:
         
     | 
| 55 | 
         
            -
                        return styled_error(f'Model "{model}" {error}')
         
     | 
| 56 | 
         
            -
             
     | 
| 57 | 
         
            -
                # Is the model info correctly filled?
         
     | 
| 58 | 
         
            -
                try:
         
     | 
| 59 | 
         
            -
                    model_info = API.model_info(repo_id=model, revision=revision)
         
     | 
| 60 | 
         
            -
                except Exception:
         
     | 
| 61 | 
         
            -
                    return styled_error("Could not get your model information. Please fill it up properly.")
         
     | 
| 62 | 
         
            -
             
     | 
| 63 | 
         
            -
                model_size = get_model_size(model_info=model_info, precision=precision)
         
     | 
| 64 | 
         
            -
             
     | 
| 65 | 
         
            -
                # Were the model card and license filled?
         
     | 
| 66 | 
         
            -
                try:
         
     | 
| 67 | 
         
            -
                    license = model_info.cardData["license"]
         
     | 
| 68 | 
         
            -
                except Exception:
         
     | 
| 69 | 
         
            -
                    return styled_error("Please select a license for your model")
         
     | 
| 70 | 
         
            -
             
     | 
| 71 | 
         
            -
                modelcard_OK, error_msg = check_model_card(model)
         
     | 
| 72 | 
         
            -
                if not modelcard_OK:
         
     | 
| 73 | 
         
            -
                    return styled_error(error_msg)
         
     | 
| 74 | 
         
            -
             
     | 
| 75 | 
         
            -
                # Seems good, creating the eval
         
     | 
| 76 | 
         
            -
                print("Adding new eval")
         
     | 
| 77 | 
         
            -
             
     | 
| 78 | 
         
            -
                eval_entry = {
         
     | 
| 79 | 
         
            -
                    "model": model,
         
     | 
| 80 | 
         
            -
                    "base_model": base_model,
         
     | 
| 81 | 
         
            -
                    "revision": revision,
         
     | 
| 82 | 
         
            -
                    "precision": precision,
         
     | 
| 83 | 
         
            -
                    "weight_type": weight_type,
         
     | 
| 84 | 
         
            -
                    "status": "PENDING",
         
     | 
| 85 | 
         
            -
                    "submitted_time": current_time,
         
     | 
| 86 | 
         
            -
                    "model_type": model_type,
         
     | 
| 87 | 
         
            -
                    "likes": model_info.likes,
         
     | 
| 88 | 
         
            -
                    "params": model_size,
         
     | 
| 89 | 
         
            -
                    "license": license,
         
     | 
| 90 | 
         
            -
                    "private": False,
         
     | 
| 91 | 
         
            -
                }
         
     | 
| 92 | 
         
            -
             
     | 
| 93 | 
         
            -
                # Check for duplicate submission
         
     | 
| 94 | 
         
            -
                if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
         
     | 
| 95 | 
         
            -
                    return styled_warning("This model has been already submitted.")
         
     | 
| 96 | 
         
            -
             
     | 
| 97 | 
         
            -
                print("Creating eval file")
         
     | 
| 98 | 
         
            -
                OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
         
     | 
| 99 | 
         
            -
                os.makedirs(OUT_DIR, exist_ok=True)
         
     | 
| 100 | 
         
            -
                out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
         
     | 
| 101 | 
         
            -
             
     | 
| 102 | 
         
            -
                with open(out_path, "w") as f:
         
     | 
| 103 | 
         
            -
                    f.write(json.dumps(eval_entry))
         
     | 
| 104 | 
         
            -
             
     | 
| 105 | 
         
            -
                print("Uploading eval file")
         
     | 
| 106 | 
         
            -
                API.upload_file(
         
     | 
| 107 | 
         
            -
                    path_or_fileobj=out_path,
         
     | 
| 108 | 
         
            -
                    path_in_repo=out_path.split("eval-queue/")[1],
         
     | 
| 109 | 
         
            -
                    repo_id=QUEUE_REPO,
         
     | 
| 110 | 
         
            -
                    repo_type="dataset",
         
     | 
| 111 | 
         
            -
                    commit_message=f"Add {model} to eval queue",
         
     | 
| 112 | 
         
            -
                )
         
     | 
| 113 | 
         
            -
             
     | 
| 114 | 
         
            -
                # Remove the local file
         
     | 
| 115 | 
         
            -
                os.remove(out_path)
         
     | 
| 116 | 
         
            -
             
     | 
| 117 | 
         
            -
                return styled_message(
         
     | 
| 118 | 
         
            -
                    "Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
         
     | 
| 119 | 
         
            -
                )
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         |