Spaces:
Build error
Build error
Commit
·
e335e03
0
Parent(s):
Initial commit with Gradio app and model loading from Hub
Browse files- .gitattributes +35 -0
- .gitignore +30 -0
- README.md +88 -0
- adapter_config.json +37 -0
- app.py +141 -0
- chat_template.jinja +5 -0
- checkpoint-250/README.md +209 -0
- checkpoint-250/adapter_config.json +37 -0
- checkpoint-250/chat_template.jinja +5 -0
- checkpoint-250/special_tokens_map.json +23 -0
- checkpoint-250/tokenizer.json +0 -0
- checkpoint-250/tokenizer_config.json +162 -0
- checkpoint-250/trainer_state.json +284 -0
- checkpoint-250/training_args.bin +3 -0
- checkpoint-300/README.md +209 -0
- checkpoint-300/adapter_config.json +37 -0
- checkpoint-300/chat_template.jinja +5 -0
- checkpoint-300/special_tokens_map.json +23 -0
- checkpoint-300/tokenizer.json +0 -0
- checkpoint-300/tokenizer_config.json +162 -0
- checkpoint-300/trainer_state.json +334 -0
- checkpoint-300/training_args.bin +3 -0
- config.json +55 -0
- configuration_deepseek.py +206 -0
- generation_config.json +9 -0
- model.safetensors.index.json +0 -0
- modeling_deepseek.py +1924 -0
- requirements.txt +8 -0
- special_tokens_map.json +23 -0
- sunlight/index.html +23 -0
- sunlight/main.js +27 -0
- sunlight/package-lock.json +802 -0
- sunlight/package.json +16 -0
- sunlight/preload.js +2 -0
- sunlight/renderer.js +20 -0
- sunlight/style.css +29 -0
- tokenization_deepseek_fast.py +38 -0
- tokenizer.json +0 -0
- tokenizer_config.json +162 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar 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
|
| 32 |
+
*.xz 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
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dependencies
|
| 2 |
+
/node_modules
|
| 3 |
+
/sunlight/node_modules
|
| 4 |
+
|
| 5 |
+
# Build artifacts
|
| 6 |
+
/dist
|
| 7 |
+
/build
|
| 8 |
+
|
| 9 |
+
# Logs
|
| 10 |
+
*.log
|
| 11 |
+
npm-debug.log*
|
| 12 |
+
yarn-debug.log*
|
| 13 |
+
yarn-error.log*
|
| 14 |
+
|
| 15 |
+
# Other
|
| 16 |
+
.DS_Store
|
| 17 |
+
.env
|
| 18 |
+
.env.local
|
| 19 |
+
.env.development.local
|
| 20 |
+
.env.test.local
|
| 21 |
+
.env.production.local
|
| 22 |
+
|
| 23 |
+
# Python
|
| 24 |
+
__pycache__/
|
| 25 |
+
*.pyc
|
| 26 |
+
*.pyo
|
| 27 |
+
*.pyd
|
| 28 |
+
.Python
|
| 29 |
+
env/
|
| 30 |
+
venv/
|
README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--
|
| 2 |
+
|
| 3 |
+
# 🧠 Zenith Copilot V1
|
| 4 |
+
### The Autonomous AI Development Partner by **AlgoRythm Technologies**
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## 🔍 Overview
|
| 9 |
+
|
| 10 |
+
**Zenith Copilot V1** is a **LoRA-adapted autonomous development model**, purpose-built to serve as the foundation for a new generation of AI-assisted software engineering.
|
| 11 |
+
Developed by **AlgoRythm Technologies**, Zenith represents the convergence of **autonomous orchestration**, **multi-language coding**, and **human-AI collaborative intelligence**.
|
| 12 |
+
|
| 13 |
+
Unlike traditional coding assistants that rely on API endpoints and external query systems, **Zenith is designed to operate independently**, capable of **fine-tuning, optimizing, and adapting** to user-driven environments.
|
| 14 |
+
It powers the backbone of AlgoRythm’s next-gen system — an environment where **code doesn’t need to be written, it’s understood**.
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## ⚙️ Model Specifications
|
| 19 |
+
|
| 20 |
+
| Property | Details |
|
| 21 |
+
|-----------|----------|
|
| 22 |
+
| **Base Model** | DeepSeek-Coder-V2-Lite-Instruct |
|
| 23 |
+
| **Architecture** | Transformer (Decoder-only) |
|
| 24 |
+
| **Parameters** | 16 Billion |
|
| 25 |
+
| **Adapter Type** | LoRA (Low-Rank Adaptation) |
|
| 26 |
+
| **Context Window** | 64K tokens |
|
| 27 |
+
| **Tokenizer** | DeepSeek BPE Extended |
|
| 28 |
+
| **Training Hardware** | NVIDIA A100 80GB (multi-node distributed) |
|
| 29 |
+
| **Precision** | bfloat16 |
|
| 30 |
+
| **Fine-tuning Framework** | PEFT + TRL |
|
| 31 |
+
| **Inference Optimizations** | FlashAttention 2, Torch Compile, TensorRT Integration |
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## 🧩 Training Objective
|
| 36 |
+
|
| 37 |
+
Zenith’s training process focused on **autonomous problem solving** and **self-directed code synthesis** rather than traditional instruction-following.
|
| 38 |
+
The model was fine-tuned using AlgoRythm’s internal *Genesis Dataset Suite*, which combines three domains:
|
| 39 |
+
|
| 40 |
+
1. **Code Intelligence Dataset (CID)** — Multi-language repositories, architecture patterns, and debugging sequences across 338 languages.
|
| 41 |
+
2. **Operational Logic Dataset (OLD)** — System-level reasoning data: CI/CD pipelines, deployment scripts, and infrastructure automation.
|
| 42 |
+
3. **Identity Dataset (ID)** — Proprietary data to enhance task recall, contextual self-adaptation, and persistent persona control.
|
| 43 |
+
|
| 44 |
+
Together, these datasets enabled Zenith to act as a **self-improving AI development agent** — one that continuously refines its approach through contextual feedback loops.
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## 🔮 Core Capabilities
|
| 49 |
+
|
| 50 |
+
- **Autonomous Project Building**
|
| 51 |
+
Zenith can generate, structure, and maintain multi-file projects with minimal human input.
|
| 52 |
+
It coordinates between backend logic, frontend design, and deployment scripts automatically.
|
| 53 |
+
|
| 54 |
+
- **Adaptive LoRA Layering**
|
| 55 |
+
The model adjusts its LoRA weights based on real-time performance data — continuously evolving without full retraining.
|
| 56 |
+
|
| 57 |
+
- **Multi-Language Reasoning**
|
| 58 |
+
With 338 supported languages, Zenith is one of the broadest multilingual coding models in existence, from Rust to COBOL to modern Pythonic frameworks.
|
| 59 |
+
|
| 60 |
+
- **Self-Diagnostics and Optimization**
|
| 61 |
+
It performs latency profiling, detects logical inefficiencies, and recommends runtime optimizations for large systems.
|
| 62 |
+
|
| 63 |
+
- **Secure On-Premise Deployment**
|
| 64 |
+
No external API dependencies. Zenith can operate inside closed environments — ensuring compliance and full data sovereignty.
|
| 65 |
+
|
| 66 |
+
---
|
| 67 |
+
|
| 68 |
+
## 🧱 Architecture Design
|
| 69 |
+
|
| 70 |
+
Zenith employs a **multi-head transformer decoder** architecture with LoRA attention layers.
|
| 71 |
+
The LoRA heads are selectively activated through AlgoRythm’s *Adaptive Precision Scaling (APS)* — a proprietary technique that adjusts compute and attention span dynamically.
|
| 72 |
+
|
| 73 |
+
This allows the model to scale from **low-latency environments** (like edge inference) to **full-scale enterprise deployments** (like cloud GPU clusters).
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## 🚀 Usage Example
|
| 78 |
+
|
| 79 |
+
```python
|
| 80 |
+
from transformers import pipeline
|
| 81 |
+
|
| 82 |
+
# Initialize Zenith Copilot V1
|
| 83 |
+
generator = pipeline("text-generation", model="AlgoRythmTechnologies/zenith_coder_v1.1", device="cuda")
|
| 84 |
+
|
| 85 |
+
prompt = "Build a responsive finance tracker using React, FastAPI, and PostgreSQL. Include authentication."
|
| 86 |
+
output = generator([{"role": "user", "content": prompt}], max_new_tokens=200, return_full_text=False)[0]
|
| 87 |
+
|
| 88 |
+
print(output["generated_text"])
|
adapter_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": null,
|
| 4 |
+
"base_model_name_or_path": "DeepSeek-Coder-V2-Lite-Instruct",
|
| 5 |
+
"bias": "none",
|
| 6 |
+
"corda_config": null,
|
| 7 |
+
"eva_config": null,
|
| 8 |
+
"exclude_modules": null,
|
| 9 |
+
"fan_in_fan_out": false,
|
| 10 |
+
"inference_mode": true,
|
| 11 |
+
"init_lora_weights": true,
|
| 12 |
+
"layer_replication": null,
|
| 13 |
+
"layers_pattern": null,
|
| 14 |
+
"layers_to_transform": null,
|
| 15 |
+
"loftq_config": {},
|
| 16 |
+
"lora_alpha": 16,
|
| 17 |
+
"lora_bias": false,
|
| 18 |
+
"lora_dropout": 0.1,
|
| 19 |
+
"megatron_config": null,
|
| 20 |
+
"megatron_core": "megatron.core",
|
| 21 |
+
"modules_to_save": null,
|
| 22 |
+
"peft_type": "LORA",
|
| 23 |
+
"qalora_group_size": 16,
|
| 24 |
+
"r": 8,
|
| 25 |
+
"rank_pattern": {},
|
| 26 |
+
"revision": null,
|
| 27 |
+
"target_modules": [
|
| 28 |
+
"q_proj",
|
| 29 |
+
"v_proj"
|
| 30 |
+
],
|
| 31 |
+
"target_parameters": null,
|
| 32 |
+
"task_type": "CAUSAL_LM",
|
| 33 |
+
"trainable_token_indices": null,
|
| 34 |
+
"use_dora": false,
|
| 35 |
+
"use_qalora": false,
|
| 36 |
+
"use_rslora": false
|
| 37 |
+
}
|
app.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import AutoTokenizer, TextIteratorStreamer, AutoModelForCausalLM
|
| 4 |
+
import requests
|
| 5 |
+
import json
|
| 6 |
+
from peft import PeftModel
|
| 7 |
+
from threading import Thread
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
# --- Configuration ---
|
| 11 |
+
# The model is loaded from the Hugging Face Hub
|
| 12 |
+
BASE_MODEL_PATH = "algorythmtechnologies/Zenith-V1.1-Coder"
|
| 13 |
+
# Name of the environment variable for the Hugging Face token
|
| 14 |
+
HF_TOKEN_ENV_VAR = "HUGGING_FACE_HUB_TOKEN"
|
| 15 |
+
|
| 16 |
+
# --- Model Loading ---
|
| 17 |
+
|
| 18 |
+
# Get the Hugging Face token from environment variables
|
| 19 |
+
hf_token = os.environ.get(HF_TOKEN_ENV_VAR)
|
| 20 |
+
|
| 21 |
+
if not hf_token:
|
| 22 |
+
raise ValueError(f"Environment variable {HF_TOKEN_ENV_VAR} not set. Please set it in your Space secrets.")
|
| 23 |
+
|
| 24 |
+
# Load the tokenizer from the Hub, using the token for private models
|
| 25 |
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_PATH, use_auth_token=hf_token)
|
| 26 |
+
|
| 27 |
+
# Load the base model from the Hub
|
| 28 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 29 |
+
BASE_MODEL_PATH,
|
| 30 |
+
trust_remote_code=True,
|
| 31 |
+
low_cpu_mem_usage=True,
|
| 32 |
+
torch_dtype=torch.bfloat16,
|
| 33 |
+
use_auth_token=hf_token
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
# Move model to the appropriate device (GPU if available, otherwise CPU)
|
| 37 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 38 |
+
base_model.to(device)
|
| 39 |
+
|
| 40 |
+
# The PEFT model is loaded from the same repository.
|
| 41 |
+
# PeftModel will automatically find the adapter configuration.
|
| 42 |
+
model = PeftModel.from_pretrained(base_model, BASE_MODEL_PATH, use_auth_token=hf_token)
|
| 43 |
+
model.eval()
|
| 44 |
+
|
| 45 |
+
# --- Web Search Function ---
|
| 46 |
+
def search(query):
|
| 47 |
+
"""Performs a web search using the Serper API."""
|
| 48 |
+
serper_api_key = os.environ.get("SERPER_API_KEY")
|
| 49 |
+
if not serper_api_key:
|
| 50 |
+
return "SERPER_API_KEY not found. Please set it as an environment variable in your Hugging Face Space secrets."
|
| 51 |
+
|
| 52 |
+
url = "https://google.serper.dev/search"
|
| 53 |
+
payload = json.dumps({"q": query})
|
| 54 |
+
headers = {
|
| 55 |
+
'X-API-KEY': serper_api_key,
|
| 56 |
+
'Content-Type': 'application/json'
|
| 57 |
+
}
|
| 58 |
+
try:
|
| 59 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
| 60 |
+
response.raise_for_status()
|
| 61 |
+
results = response.json()
|
| 62 |
+
return results.get('organic', [])
|
| 63 |
+
except requests.exceptions.RequestException as e:
|
| 64 |
+
return f"Error during web search: {e}"
|
| 65 |
+
|
| 66 |
+
# --- Response Generation ---
|
| 67 |
+
def generate_response(message, history):
|
| 68 |
+
"""Generates a response from the model, with optional web search."""
|
| 69 |
+
|
| 70 |
+
# Handle web search command
|
| 71 |
+
if message.lower().startswith("search for "):
|
| 72 |
+
search_query = message[len("search for "):]
|
| 73 |
+
search_results = search(search_query)
|
| 74 |
+
|
| 75 |
+
if isinstance(search_results, str): # Error case
|
| 76 |
+
yield search_results
|
| 77 |
+
return
|
| 78 |
+
|
| 79 |
+
if not search_results:
|
| 80 |
+
yield "No search results found."
|
| 81 |
+
return
|
| 82 |
+
|
| 83 |
+
context = " ".join([res.get('snippet', '') for res in search_results[:5]])
|
| 84 |
+
# Prepend context to the user's message
|
| 85 |
+
message = f"Based on the following search results, answer the user's query.\nContext: {context}\n\nUser Query: {message}"
|
| 86 |
+
|
| 87 |
+
# Format chat history and new message using the tokenizer's chat template
|
| 88 |
+
chat_messages = []
|
| 89 |
+
for user_msg, assistant_msg in history:
|
| 90 |
+
chat_messages.append({"role": "user", "content": user_msg})
|
| 91 |
+
if assistant_msg:
|
| 92 |
+
chat_messages.append({"role": "assistant", "content": assistant_msg})
|
| 93 |
+
chat_messages.append({"role": "user", "content": message})
|
| 94 |
+
|
| 95 |
+
# Apply the chat template
|
| 96 |
+
prompt = tokenizer.apply_chat_template(chat_messages, tokenize=False, add_generation_prompt=True)
|
| 97 |
+
|
| 98 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(device)
|
| 99 |
+
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 100 |
+
|
| 101 |
+
generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=1024)
|
| 102 |
+
|
| 103 |
+
# Run generation in a separate thread
|
| 104 |
+
thread = Thread(target=model.generate, kwargs=generation_kwargs)
|
| 105 |
+
thread.start()
|
| 106 |
+
|
| 107 |
+
# Yield generated text as it becomes available
|
| 108 |
+
generated_text = ""
|
| 109 |
+
for new_text in streamer:
|
| 110 |
+
generated_text += new_text
|
| 111 |
+
yield generated_text
|
| 112 |
+
|
| 113 |
+
# --- Gradio UI ---
|
| 114 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="sky", secondary_hue="blue")) as demo:
|
| 115 |
+
gr.HTML("<h1 align='center'>Zenith V1.1 Coder</h1>")
|
| 116 |
+
gr.Markdown("This Space is running [Zenith-V1.1-Coder](https://huggingface.co/algorythmtechnologies/Zenith-V1.1-Coder).<br>You can ask coding questions or use the 'search for <query>' command to browse the web.")
|
| 117 |
+
|
| 118 |
+
gr.ChatInterface(
|
| 119 |
+
generate_response,
|
| 120 |
+
chatbot=gr.Chatbot(
|
| 121 |
+
height=600,
|
| 122 |
+
avatar_images=(None, "https://i.imgur.com/9kAC4pG.png"),
|
| 123 |
+
bubble_full_width=False,
|
| 124 |
+
),
|
| 125 |
+
textbox=gr.Textbox(
|
| 126 |
+
placeholder="Ask me a question or type 'search for <your query>'...",
|
| 127 |
+
container=False,
|
| 128 |
+
scale=7,
|
| 129 |
+
),
|
| 130 |
+
submit_btn="Send",
|
| 131 |
+
retry_btn=None,
|
| 132 |
+
undo_btn=None,
|
| 133 |
+
clear_btn="Clear History",
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
if __name__ == "__main__":
|
| 137 |
+
# Before launching, remind the user to set the token if it's not found.
|
| 138 |
+
if not os.environ.get(HF_TOKEN_ENV_VAR):
|
| 139 |
+
print(f"CRITICAL: Environment variable {HF_TOKEN_ENV_VAR} not found.")
|
| 140 |
+
print("Please set this as a secret in your Hugging Face Space settings.")
|
| 141 |
+
demo.launch(share=True)
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '
|
| 2 |
+
|
| 3 |
+
' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '
|
| 4 |
+
|
| 5 |
+
' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
checkpoint-250/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: DeepSeek-Coder-V2-Lite-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:DeepSeek-Coder-V2-Lite-Instruct
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Model Card for Model ID
|
| 14 |
+
|
| 15 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
|
| 21 |
+
### Model Description
|
| 22 |
+
|
| 23 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
- **Developed by:** [More Information Needed]
|
| 28 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
+
- **Model type:** [More Information Needed]
|
| 31 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
+
- **License:** [More Information Needed]
|
| 33 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
+
|
| 35 |
+
### Model Sources [optional]
|
| 36 |
+
|
| 37 |
+
<!-- Provide the basic links for the model. -->
|
| 38 |
+
|
| 39 |
+
- **Repository:** [More Information Needed]
|
| 40 |
+
- **Paper [optional]:** [More Information Needed]
|
| 41 |
+
- **Demo [optional]:** [More Information Needed]
|
| 42 |
+
|
| 43 |
+
## Uses
|
| 44 |
+
|
| 45 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 46 |
+
|
| 47 |
+
### Direct Use
|
| 48 |
+
|
| 49 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 50 |
+
|
| 51 |
+
[More Information Needed]
|
| 52 |
+
|
| 53 |
+
### Downstream Use [optional]
|
| 54 |
+
|
| 55 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 56 |
+
|
| 57 |
+
[More Information Needed]
|
| 58 |
+
|
| 59 |
+
### Out-of-Scope Use
|
| 60 |
+
|
| 61 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 62 |
+
|
| 63 |
+
[More Information Needed]
|
| 64 |
+
|
| 65 |
+
## Bias, Risks, and Limitations
|
| 66 |
+
|
| 67 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 68 |
+
|
| 69 |
+
[More Information Needed]
|
| 70 |
+
|
| 71 |
+
### Recommendations
|
| 72 |
+
|
| 73 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 74 |
+
|
| 75 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 76 |
+
|
| 77 |
+
## How to Get Started with the Model
|
| 78 |
+
|
| 79 |
+
Use the code below to get started with the model.
|
| 80 |
+
|
| 81 |
+
[More Information Needed]
|
| 82 |
+
|
| 83 |
+
## Training Details
|
| 84 |
+
|
| 85 |
+
### Training Data
|
| 86 |
+
|
| 87 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 88 |
+
|
| 89 |
+
[More Information Needed]
|
| 90 |
+
|
| 91 |
+
### Training Procedure
|
| 92 |
+
|
| 93 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 94 |
+
|
| 95 |
+
#### Preprocessing [optional]
|
| 96 |
+
|
| 97 |
+
[More Information Needed]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
#### Training Hyperparameters
|
| 101 |
+
|
| 102 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 103 |
+
|
| 104 |
+
#### Speeds, Sizes, Times [optional]
|
| 105 |
+
|
| 106 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 107 |
+
|
| 108 |
+
[More Information Needed]
|
| 109 |
+
|
| 110 |
+
## Evaluation
|
| 111 |
+
|
| 112 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 113 |
+
|
| 114 |
+
### Testing Data, Factors & Metrics
|
| 115 |
+
|
| 116 |
+
#### Testing Data
|
| 117 |
+
|
| 118 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 119 |
+
|
| 120 |
+
[More Information Needed]
|
| 121 |
+
|
| 122 |
+
#### Factors
|
| 123 |
+
|
| 124 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 125 |
+
|
| 126 |
+
[More Information Needed]
|
| 127 |
+
|
| 128 |
+
#### Metrics
|
| 129 |
+
|
| 130 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 131 |
+
|
| 132 |
+
[More Information Needed]
|
| 133 |
+
|
| 134 |
+
### Results
|
| 135 |
+
|
| 136 |
+
[More Information Needed]
|
| 137 |
+
|
| 138 |
+
#### Summary
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## Model Examination [optional]
|
| 143 |
+
|
| 144 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 145 |
+
|
| 146 |
+
[More Information Needed]
|
| 147 |
+
|
| 148 |
+
## Environmental Impact
|
| 149 |
+
|
| 150 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 151 |
+
|
| 152 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 153 |
+
|
| 154 |
+
- **Hardware Type:** [More Information Needed]
|
| 155 |
+
- **Hours used:** [More Information Needed]
|
| 156 |
+
- **Cloud Provider:** [More Information Needed]
|
| 157 |
+
- **Compute Region:** [More Information Needed]
|
| 158 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 159 |
+
|
| 160 |
+
## Technical Specifications [optional]
|
| 161 |
+
|
| 162 |
+
### Model Architecture and Objective
|
| 163 |
+
|
| 164 |
+
[More Information Needed]
|
| 165 |
+
|
| 166 |
+
### Compute Infrastructure
|
| 167 |
+
|
| 168 |
+
[More Information Needed]
|
| 169 |
+
|
| 170 |
+
#### Hardware
|
| 171 |
+
|
| 172 |
+
[More Information Needed]
|
| 173 |
+
|
| 174 |
+
#### Software
|
| 175 |
+
|
| 176 |
+
[More Information Needed]
|
| 177 |
+
|
| 178 |
+
## Citation [optional]
|
| 179 |
+
|
| 180 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 181 |
+
|
| 182 |
+
**BibTeX:**
|
| 183 |
+
|
| 184 |
+
[More Information Needed]
|
| 185 |
+
|
| 186 |
+
**APA:**
|
| 187 |
+
|
| 188 |
+
[More Information Needed]
|
| 189 |
+
|
| 190 |
+
## Glossary [optional]
|
| 191 |
+
|
| 192 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 193 |
+
|
| 194 |
+
[More Information Needed]
|
| 195 |
+
|
| 196 |
+
## More Information [optional]
|
| 197 |
+
|
| 198 |
+
[More Information Needed]
|
| 199 |
+
|
| 200 |
+
## Model Card Authors [optional]
|
| 201 |
+
|
| 202 |
+
[More Information Needed]
|
| 203 |
+
|
| 204 |
+
## Model Card Contact
|
| 205 |
+
|
| 206 |
+
[More Information Needed]
|
| 207 |
+
### Framework versions
|
| 208 |
+
|
| 209 |
+
- PEFT 0.17.1
|
checkpoint-250/adapter_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": null,
|
| 4 |
+
"base_model_name_or_path": "DeepSeek-Coder-V2-Lite-Instruct",
|
| 5 |
+
"bias": "none",
|
| 6 |
+
"corda_config": null,
|
| 7 |
+
"eva_config": null,
|
| 8 |
+
"exclude_modules": null,
|
| 9 |
+
"fan_in_fan_out": false,
|
| 10 |
+
"inference_mode": true,
|
| 11 |
+
"init_lora_weights": true,
|
| 12 |
+
"layer_replication": null,
|
| 13 |
+
"layers_pattern": null,
|
| 14 |
+
"layers_to_transform": null,
|
| 15 |
+
"loftq_config": {},
|
| 16 |
+
"lora_alpha": 16,
|
| 17 |
+
"lora_bias": false,
|
| 18 |
+
"lora_dropout": 0.1,
|
| 19 |
+
"megatron_config": null,
|
| 20 |
+
"megatron_core": "megatron.core",
|
| 21 |
+
"modules_to_save": null,
|
| 22 |
+
"peft_type": "LORA",
|
| 23 |
+
"qalora_group_size": 16,
|
| 24 |
+
"r": 8,
|
| 25 |
+
"rank_pattern": {},
|
| 26 |
+
"revision": null,
|
| 27 |
+
"target_modules": [
|
| 28 |
+
"q_proj",
|
| 29 |
+
"v_proj"
|
| 30 |
+
],
|
| 31 |
+
"target_parameters": null,
|
| 32 |
+
"task_type": "CAUSAL_LM",
|
| 33 |
+
"trainable_token_indices": null,
|
| 34 |
+
"use_dora": false,
|
| 35 |
+
"use_qalora": false,
|
| 36 |
+
"use_rslora": false
|
| 37 |
+
}
|
checkpoint-250/chat_template.jinja
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '
|
| 2 |
+
|
| 3 |
+
' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '
|
| 4 |
+
|
| 5 |
+
' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
checkpoint-250/special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|begin▁of▁sentence|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": true,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|end▁of▁sentence|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": true,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<|end▁of▁sentence|>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": true,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
checkpoint-250/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
checkpoint-250/tokenizer_config.json
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"add_prefix_space": null,
|
| 5 |
+
"added_tokens_decoder": {
|
| 6 |
+
"100000": {
|
| 7 |
+
"content": "<|begin▁of▁sentence|>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": true,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false,
|
| 12 |
+
"special": true
|
| 13 |
+
},
|
| 14 |
+
"100001": {
|
| 15 |
+
"content": "<|end▁of▁sentence|>",
|
| 16 |
+
"lstrip": false,
|
| 17 |
+
"normalized": true,
|
| 18 |
+
"rstrip": false,
|
| 19 |
+
"single_word": false,
|
| 20 |
+
"special": true
|
| 21 |
+
},
|
| 22 |
+
"100002": {
|
| 23 |
+
"content": "<|fim▁hole|>",
|
| 24 |
+
"lstrip": false,
|
| 25 |
+
"normalized": true,
|
| 26 |
+
"rstrip": false,
|
| 27 |
+
"single_word": false,
|
| 28 |
+
"special": false
|
| 29 |
+
},
|
| 30 |
+
"100003": {
|
| 31 |
+
"content": "<|fim▁begin|>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": true,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false,
|
| 36 |
+
"special": false
|
| 37 |
+
},
|
| 38 |
+
"100004": {
|
| 39 |
+
"content": "<|fim▁end|>",
|
| 40 |
+
"lstrip": false,
|
| 41 |
+
"normalized": true,
|
| 42 |
+
"rstrip": false,
|
| 43 |
+
"single_word": false,
|
| 44 |
+
"special": false
|
| 45 |
+
},
|
| 46 |
+
"100005": {
|
| 47 |
+
"content": "<|completion|>",
|
| 48 |
+
"lstrip": false,
|
| 49 |
+
"normalized": true,
|
| 50 |
+
"rstrip": false,
|
| 51 |
+
"single_word": false,
|
| 52 |
+
"special": false
|
| 53 |
+
},
|
| 54 |
+
"100006": {
|
| 55 |
+
"content": "<|User|>",
|
| 56 |
+
"lstrip": false,
|
| 57 |
+
"normalized": true,
|
| 58 |
+
"rstrip": false,
|
| 59 |
+
"single_word": false,
|
| 60 |
+
"special": false
|
| 61 |
+
},
|
| 62 |
+
"100007": {
|
| 63 |
+
"content": "<|Assistant|>",
|
| 64 |
+
"lstrip": false,
|
| 65 |
+
"normalized": true,
|
| 66 |
+
"rstrip": false,
|
| 67 |
+
"single_word": false,
|
| 68 |
+
"special": false
|
| 69 |
+
},
|
| 70 |
+
"100008": {
|
| 71 |
+
"content": "<|EOT|>",
|
| 72 |
+
"lstrip": false,
|
| 73 |
+
"normalized": true,
|
| 74 |
+
"rstrip": false,
|
| 75 |
+
"single_word": false,
|
| 76 |
+
"special": true
|
| 77 |
+
},
|
| 78 |
+
"100009": {
|
| 79 |
+
"content": "<|tool▁calls▁begin|>",
|
| 80 |
+
"lstrip": false,
|
| 81 |
+
"normalized": true,
|
| 82 |
+
"rstrip": false,
|
| 83 |
+
"single_word": false,
|
| 84 |
+
"special": false
|
| 85 |
+
},
|
| 86 |
+
"100010": {
|
| 87 |
+
"content": "<|tool▁calls▁end|>",
|
| 88 |
+
"lstrip": false,
|
| 89 |
+
"normalized": true,
|
| 90 |
+
"rstrip": false,
|
| 91 |
+
"single_word": false,
|
| 92 |
+
"special": false
|
| 93 |
+
},
|
| 94 |
+
"100011": {
|
| 95 |
+
"content": "<|tool▁call▁begin|>",
|
| 96 |
+
"lstrip": false,
|
| 97 |
+
"normalized": true,
|
| 98 |
+
"rstrip": false,
|
| 99 |
+
"single_word": false,
|
| 100 |
+
"special": false
|
| 101 |
+
},
|
| 102 |
+
"100012": {
|
| 103 |
+
"content": "<|tool▁call▁end|>",
|
| 104 |
+
"lstrip": false,
|
| 105 |
+
"normalized": true,
|
| 106 |
+
"rstrip": false,
|
| 107 |
+
"single_word": false,
|
| 108 |
+
"special": false
|
| 109 |
+
},
|
| 110 |
+
"100013": {
|
| 111 |
+
"content": "<|tool▁outputs▁begin|>",
|
| 112 |
+
"lstrip": false,
|
| 113 |
+
"normalized": true,
|
| 114 |
+
"rstrip": false,
|
| 115 |
+
"single_word": false,
|
| 116 |
+
"special": false
|
| 117 |
+
},
|
| 118 |
+
"100014": {
|
| 119 |
+
"content": "<|tool▁outputs▁end|>",
|
| 120 |
+
"lstrip": false,
|
| 121 |
+
"normalized": true,
|
| 122 |
+
"rstrip": false,
|
| 123 |
+
"single_word": false,
|
| 124 |
+
"special": false
|
| 125 |
+
},
|
| 126 |
+
"100015": {
|
| 127 |
+
"content": "<|tool▁output▁begin|>",
|
| 128 |
+
"lstrip": false,
|
| 129 |
+
"normalized": true,
|
| 130 |
+
"rstrip": false,
|
| 131 |
+
"single_word": false,
|
| 132 |
+
"special": false
|
| 133 |
+
},
|
| 134 |
+
"100016": {
|
| 135 |
+
"content": "<|tool▁output▁end|>",
|
| 136 |
+
"lstrip": false,
|
| 137 |
+
"normalized": true,
|
| 138 |
+
"rstrip": false,
|
| 139 |
+
"single_word": false,
|
| 140 |
+
"special": false
|
| 141 |
+
},
|
| 142 |
+
"100017": {
|
| 143 |
+
"content": "<|tool▁sep|>",
|
| 144 |
+
"lstrip": false,
|
| 145 |
+
"normalized": true,
|
| 146 |
+
"rstrip": false,
|
| 147 |
+
"single_word": false,
|
| 148 |
+
"special": false
|
| 149 |
+
}
|
| 150 |
+
},
|
| 151 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
| 152 |
+
"clean_up_tokenization_spaces": false,
|
| 153 |
+
"eos_token": "<|end▁of▁sentence|>",
|
| 154 |
+
"extra_special_tokens": {},
|
| 155 |
+
"legacy": true,
|
| 156 |
+
"model_max_length": 16384,
|
| 157 |
+
"pad_token": "<|end▁of▁sentence|>",
|
| 158 |
+
"sp_model_kwargs": {},
|
| 159 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
| 160 |
+
"unk_token": null,
|
| 161 |
+
"use_default_system_prompt": false
|
| 162 |
+
}
|
checkpoint-250/trainer_state.json
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 83.33333333333333,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 250,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"entropy": 1.9060055136680603,
|
| 14 |
+
"epoch": 3.3333333333333335,
|
| 15 |
+
"grad_norm": 1.0164649486541748,
|
| 16 |
+
"learning_rate": 1.5e-05,
|
| 17 |
+
"loss": 4.1011,
|
| 18 |
+
"mean_token_accuracy": 0.4009168431162834,
|
| 19 |
+
"num_tokens": 5512.0,
|
| 20 |
+
"step": 10
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"entropy": 1.9487085342407227,
|
| 24 |
+
"epoch": 6.666666666666667,
|
| 25 |
+
"grad_norm": 0.9628961682319641,
|
| 26 |
+
"learning_rate": 3.1666666666666666e-05,
|
| 27 |
+
"loss": 4.1923,
|
| 28 |
+
"mean_token_accuracy": 0.39442635476589205,
|
| 29 |
+
"num_tokens": 10326.0,
|
| 30 |
+
"step": 20
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"entropy": 1.8993895709514619,
|
| 34 |
+
"epoch": 10.0,
|
| 35 |
+
"grad_norm": 1.177027702331543,
|
| 36 |
+
"learning_rate": 4.8333333333333334e-05,
|
| 37 |
+
"loss": 4.0334,
|
| 38 |
+
"mean_token_accuracy": 0.40877673774957657,
|
| 39 |
+
"num_tokens": 15462.0,
|
| 40 |
+
"step": 30
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"entropy": 1.9950154840946197,
|
| 44 |
+
"epoch": 13.333333333333334,
|
| 45 |
+
"grad_norm": 1.436251163482666,
|
| 46 |
+
"learning_rate": 4.9863047384206835e-05,
|
| 47 |
+
"loss": 3.9342,
|
| 48 |
+
"mean_token_accuracy": 0.40931957215070724,
|
| 49 |
+
"num_tokens": 20681.0,
|
| 50 |
+
"step": 40
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"entropy": 2.067208158969879,
|
| 54 |
+
"epoch": 16.666666666666668,
|
| 55 |
+
"grad_norm": 1.078131079673767,
|
| 56 |
+
"learning_rate": 4.939155700460536e-05,
|
| 57 |
+
"loss": 3.7698,
|
| 58 |
+
"mean_token_accuracy": 0.42098456621170044,
|
| 59 |
+
"num_tokens": 26109.0,
|
| 60 |
+
"step": 50
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"entropy": 2.193948692083359,
|
| 64 |
+
"epoch": 20.0,
|
| 65 |
+
"grad_norm": 1.1934932470321655,
|
| 66 |
+
"learning_rate": 4.859021265983959e-05,
|
| 67 |
+
"loss": 3.6115,
|
| 68 |
+
"mean_token_accuracy": 0.43236732184886933,
|
| 69 |
+
"num_tokens": 31244.0,
|
| 70 |
+
"step": 60
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"entropy": 2.4151065587997436,
|
| 74 |
+
"epoch": 23.333333333333332,
|
| 75 |
+
"grad_norm": 0.8595532774925232,
|
| 76 |
+
"learning_rate": 4.7469851157479177e-05,
|
| 77 |
+
"loss": 3.5401,
|
| 78 |
+
"mean_token_accuracy": 0.42654525190591813,
|
| 79 |
+
"num_tokens": 36738.0,
|
| 80 |
+
"step": 70
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"entropy": 2.4695091366767885,
|
| 84 |
+
"epoch": 26.666666666666668,
|
| 85 |
+
"grad_norm": 0.9981549978256226,
|
| 86 |
+
"learning_rate": 4.604562346488144e-05,
|
| 87 |
+
"loss": 3.3173,
|
| 88 |
+
"mean_token_accuracy": 0.4566218167543411,
|
| 89 |
+
"num_tokens": 41886.0,
|
| 90 |
+
"step": 80
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"entropy": 2.4938253283500673,
|
| 94 |
+
"epoch": 30.0,
|
| 95 |
+
"grad_norm": 0.5646995902061462,
|
| 96 |
+
"learning_rate": 4.43367898183491e-05,
|
| 97 |
+
"loss": 3.1822,
|
| 98 |
+
"mean_token_accuracy": 0.4696041285991669,
|
| 99 |
+
"num_tokens": 46983.0,
|
| 100 |
+
"step": 90
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"entropy": 2.564500260353088,
|
| 104 |
+
"epoch": 33.333333333333336,
|
| 105 |
+
"grad_norm": 0.8602616786956787,
|
| 106 |
+
"learning_rate": 4.2366459261474933e-05,
|
| 107 |
+
"loss": 3.1409,
|
| 108 |
+
"mean_token_accuracy": 0.47821263819932935,
|
| 109 |
+
"num_tokens": 52150.0,
|
| 110 |
+
"step": 100
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"entropy": 2.5386017203330993,
|
| 114 |
+
"epoch": 36.666666666666664,
|
| 115 |
+
"grad_norm": 0.7394922971725464,
|
| 116 |
+
"learning_rate": 4.0161277134970345e-05,
|
| 117 |
+
"loss": 2.9888,
|
| 118 |
+
"mean_token_accuracy": 0.49289675503969194,
|
| 119 |
+
"num_tokens": 57240.0,
|
| 120 |
+
"step": 110
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"entropy": 2.5600393176078797,
|
| 124 |
+
"epoch": 40.0,
|
| 125 |
+
"grad_norm": 0.6606329083442688,
|
| 126 |
+
"learning_rate": 3.775106474414188e-05,
|
| 127 |
+
"loss": 2.9445,
|
| 128 |
+
"mean_token_accuracy": 0.5016584262251854,
|
| 129 |
+
"num_tokens": 62806.0,
|
| 130 |
+
"step": 120
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"entropy": 2.547697913646698,
|
| 134 |
+
"epoch": 43.333333333333336,
|
| 135 |
+
"grad_norm": 0.8845142126083374,
|
| 136 |
+
"learning_rate": 3.516841607689501e-05,
|
| 137 |
+
"loss": 2.9015,
|
| 138 |
+
"mean_token_accuracy": 0.5097966089844703,
|
| 139 |
+
"num_tokens": 67877.0,
|
| 140 |
+
"step": 130
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"entropy": 2.5584489583969114,
|
| 144 |
+
"epoch": 46.666666666666664,
|
| 145 |
+
"grad_norm": 0.8559042811393738,
|
| 146 |
+
"learning_rate": 3.244825702596205e-05,
|
| 147 |
+
"loss": 2.9204,
|
| 148 |
+
"mean_token_accuracy": 0.503237409889698,
|
| 149 |
+
"num_tokens": 73030.0,
|
| 150 |
+
"step": 140
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"entropy": 2.479199802875519,
|
| 154 |
+
"epoch": 50.0,
|
| 155 |
+
"grad_norm": 0.9662401080131531,
|
| 156 |
+
"learning_rate": 2.9627373076117863e-05,
|
| 157 |
+
"loss": 2.7848,
|
| 158 |
+
"mean_token_accuracy": 0.5199230208992958,
|
| 159 |
+
"num_tokens": 78133.0,
|
| 160 |
+
"step": 150
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"entropy": 2.451095724105835,
|
| 164 |
+
"epoch": 53.333333333333336,
|
| 165 |
+
"grad_norm": 0.7248209714889526,
|
| 166 |
+
"learning_rate": 2.674391184360313e-05,
|
| 167 |
+
"loss": 2.72,
|
| 168 |
+
"mean_token_accuracy": 0.530137126147747,
|
| 169 |
+
"num_tokens": 83587.0,
|
| 170 |
+
"step": 160
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"entropy": 2.4100263833999636,
|
| 174 |
+
"epoch": 56.666666666666664,
|
| 175 |
+
"grad_norm": 0.8213902115821838,
|
| 176 |
+
"learning_rate": 2.3836867195056335e-05,
|
| 177 |
+
"loss": 2.6899,
|
| 178 |
+
"mean_token_accuracy": 0.5364036962389946,
|
| 179 |
+
"num_tokens": 88745.0,
|
| 180 |
+
"step": 170
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"entropy": 2.3743161976337435,
|
| 184 |
+
"epoch": 60.0,
|
| 185 |
+
"grad_norm": 0.9216499924659729,
|
| 186 |
+
"learning_rate": 2.0945551922360818e-05,
|
| 187 |
+
"loss": 2.6164,
|
| 188 |
+
"mean_token_accuracy": 0.5464533418416977,
|
| 189 |
+
"num_tokens": 93971.0,
|
| 190 |
+
"step": 180
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"entropy": 2.3309614181518556,
|
| 194 |
+
"epoch": 63.333333333333336,
|
| 195 |
+
"grad_norm": 0.9028099179267883,
|
| 196 |
+
"learning_rate": 1.8109066104575023e-05,
|
| 197 |
+
"loss": 2.577,
|
| 198 |
+
"mean_token_accuracy": 0.5494851708412171,
|
| 199 |
+
"num_tokens": 99176.0,
|
| 200 |
+
"step": 190
|
| 201 |
+
},
|
| 202 |
+
{
|
| 203 |
+
"entropy": 2.3660804867744445,
|
| 204 |
+
"epoch": 66.66666666666667,
|
| 205 |
+
"grad_norm": 1.1050912141799927,
|
| 206 |
+
"learning_rate": 1.5365768346438797e-05,
|
| 207 |
+
"loss": 2.6015,
|
| 208 |
+
"mean_token_accuracy": 0.5429237529635429,
|
| 209 |
+
"num_tokens": 104369.0,
|
| 210 |
+
"step": 200
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"entropy": 2.2412913620471953,
|
| 214 |
+
"epoch": 70.0,
|
| 215 |
+
"grad_norm": 1.1248013973236084,
|
| 216 |
+
"learning_rate": 1.2752757044047827e-05,
|
| 217 |
+
"loss": 2.4471,
|
| 218 |
+
"mean_token_accuracy": 0.5652078241109848,
|
| 219 |
+
"num_tokens": 109867.0,
|
| 220 |
+
"step": 210
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"entropy": 2.2687363147735597,
|
| 224 |
+
"epoch": 73.33333333333333,
|
| 225 |
+
"grad_norm": 0.8138008117675781,
|
| 226 |
+
"learning_rate": 1.0305368692688174e-05,
|
| 227 |
+
"loss": 2.4754,
|
| 228 |
+
"mean_token_accuracy": 0.5577909976243973,
|
| 229 |
+
"num_tokens": 115316.0,
|
| 230 |
+
"step": 220
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"entropy": 2.2360614061355593,
|
| 234 |
+
"epoch": 76.66666666666667,
|
| 235 |
+
"grad_norm": 0.9668932557106018,
|
| 236 |
+
"learning_rate": 8.056700021356694e-06,
|
| 237 |
+
"loss": 2.4623,
|
| 238 |
+
"mean_token_accuracy": 0.5630308628082276,
|
| 239 |
+
"num_tokens": 120487.0,
|
| 240 |
+
"step": 230
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"entropy": 2.28078556060791,
|
| 244 |
+
"epoch": 80.0,
|
| 245 |
+
"grad_norm": 0.9901016354560852,
|
| 246 |
+
"learning_rate": 6.037160416278278e-06,
|
| 247 |
+
"loss": 2.5002,
|
| 248 |
+
"mean_token_accuracy": 0.5567112416028976,
|
| 249 |
+
"num_tokens": 125629.0,
|
| 250 |
+
"step": 240
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"entropy": 2.2194084882736207,
|
| 254 |
+
"epoch": 83.33333333333333,
|
| 255 |
+
"grad_norm": 1.047966480255127,
|
| 256 |
+
"learning_rate": 4.274060686123959e-06,
|
| 257 |
+
"loss": 2.418,
|
| 258 |
+
"mean_token_accuracy": 0.5643551826477051,
|
| 259 |
+
"num_tokens": 130811.0,
|
| 260 |
+
"step": 250
|
| 261 |
+
}
|
| 262 |
+
],
|
| 263 |
+
"logging_steps": 10,
|
| 264 |
+
"max_steps": 300,
|
| 265 |
+
"num_input_tokens_seen": 0,
|
| 266 |
+
"num_train_epochs": 100,
|
| 267 |
+
"save_steps": 50,
|
| 268 |
+
"stateful_callbacks": {
|
| 269 |
+
"TrainerControl": {
|
| 270 |
+
"args": {
|
| 271 |
+
"should_epoch_stop": false,
|
| 272 |
+
"should_evaluate": false,
|
| 273 |
+
"should_log": false,
|
| 274 |
+
"should_save": true,
|
| 275 |
+
"should_training_stop": false
|
| 276 |
+
},
|
| 277 |
+
"attributes": {}
|
| 278 |
+
}
|
| 279 |
+
},
|
| 280 |
+
"total_flos": 1.5636363954499584e+16,
|
| 281 |
+
"train_batch_size": 2,
|
| 282 |
+
"trial_name": null,
|
| 283 |
+
"trial_params": null
|
| 284 |
+
}
|
checkpoint-250/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0732842102da7bf8db229d843550c94a8d413ab0b06dfc753dfe4e84b41a97c
|
| 3 |
+
size 6161
|
checkpoint-300/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: DeepSeek-Coder-V2-Lite-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:DeepSeek-Coder-V2-Lite-Instruct
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Model Card for Model ID
|
| 14 |
+
|
| 15 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
|
| 21 |
+
### Model Description
|
| 22 |
+
|
| 23 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
- **Developed by:** [More Information Needed]
|
| 28 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
+
- **Model type:** [More Information Needed]
|
| 31 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
+
- **License:** [More Information Needed]
|
| 33 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
+
|
| 35 |
+
### Model Sources [optional]
|
| 36 |
+
|
| 37 |
+
<!-- Provide the basic links for the model. -->
|
| 38 |
+
|
| 39 |
+
- **Repository:** [More Information Needed]
|
| 40 |
+
- **Paper [optional]:** [More Information Needed]
|
| 41 |
+
- **Demo [optional]:** [More Information Needed]
|
| 42 |
+
|
| 43 |
+
## Uses
|
| 44 |
+
|
| 45 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 46 |
+
|
| 47 |
+
### Direct Use
|
| 48 |
+
|
| 49 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 50 |
+
|
| 51 |
+
[More Information Needed]
|
| 52 |
+
|
| 53 |
+
### Downstream Use [optional]
|
| 54 |
+
|
| 55 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 56 |
+
|
| 57 |
+
[More Information Needed]
|
| 58 |
+
|
| 59 |
+
### Out-of-Scope Use
|
| 60 |
+
|
| 61 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 62 |
+
|
| 63 |
+
[More Information Needed]
|
| 64 |
+
|
| 65 |
+
## Bias, Risks, and Limitations
|
| 66 |
+
|
| 67 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 68 |
+
|
| 69 |
+
[More Information Needed]
|
| 70 |
+
|
| 71 |
+
### Recommendations
|
| 72 |
+
|
| 73 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 74 |
+
|
| 75 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 76 |
+
|
| 77 |
+
## How to Get Started with the Model
|
| 78 |
+
|
| 79 |
+
Use the code below to get started with the model.
|
| 80 |
+
|
| 81 |
+
[More Information Needed]
|
| 82 |
+
|
| 83 |
+
## Training Details
|
| 84 |
+
|
| 85 |
+
### Training Data
|
| 86 |
+
|
| 87 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 88 |
+
|
| 89 |
+
[More Information Needed]
|
| 90 |
+
|
| 91 |
+
### Training Procedure
|
| 92 |
+
|
| 93 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 94 |
+
|
| 95 |
+
#### Preprocessing [optional]
|
| 96 |
+
|
| 97 |
+
[More Information Needed]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
#### Training Hyperparameters
|
| 101 |
+
|
| 102 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 103 |
+
|
| 104 |
+
#### Speeds, Sizes, Times [optional]
|
| 105 |
+
|
| 106 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 107 |
+
|
| 108 |
+
[More Information Needed]
|
| 109 |
+
|
| 110 |
+
## Evaluation
|
| 111 |
+
|
| 112 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 113 |
+
|
| 114 |
+
### Testing Data, Factors & Metrics
|
| 115 |
+
|
| 116 |
+
#### Testing Data
|
| 117 |
+
|
| 118 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 119 |
+
|
| 120 |
+
[More Information Needed]
|
| 121 |
+
|
| 122 |
+
#### Factors
|
| 123 |
+
|
| 124 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 125 |
+
|
| 126 |
+
[More Information Needed]
|
| 127 |
+
|
| 128 |
+
#### Metrics
|
| 129 |
+
|
| 130 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 131 |
+
|
| 132 |
+
[More Information Needed]
|
| 133 |
+
|
| 134 |
+
### Results
|
| 135 |
+
|
| 136 |
+
[More Information Needed]
|
| 137 |
+
|
| 138 |
+
#### Summary
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## Model Examination [optional]
|
| 143 |
+
|
| 144 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 145 |
+
|
| 146 |
+
[More Information Needed]
|
| 147 |
+
|
| 148 |
+
## Environmental Impact
|
| 149 |
+
|
| 150 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 151 |
+
|
| 152 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 153 |
+
|
| 154 |
+
- **Hardware Type:** [More Information Needed]
|
| 155 |
+
- **Hours used:** [More Information Needed]
|
| 156 |
+
- **Cloud Provider:** [More Information Needed]
|
| 157 |
+
- **Compute Region:** [More Information Needed]
|
| 158 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 159 |
+
|
| 160 |
+
## Technical Specifications [optional]
|
| 161 |
+
|
| 162 |
+
### Model Architecture and Objective
|
| 163 |
+
|
| 164 |
+
[More Information Needed]
|
| 165 |
+
|
| 166 |
+
### Compute Infrastructure
|
| 167 |
+
|
| 168 |
+
[More Information Needed]
|
| 169 |
+
|
| 170 |
+
#### Hardware
|
| 171 |
+
|
| 172 |
+
[More Information Needed]
|
| 173 |
+
|
| 174 |
+
#### Software
|
| 175 |
+
|
| 176 |
+
[More Information Needed]
|
| 177 |
+
|
| 178 |
+
## Citation [optional]
|
| 179 |
+
|
| 180 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 181 |
+
|
| 182 |
+
**BibTeX:**
|
| 183 |
+
|
| 184 |
+
[More Information Needed]
|
| 185 |
+
|
| 186 |
+
**APA:**
|
| 187 |
+
|
| 188 |
+
[More Information Needed]
|
| 189 |
+
|
| 190 |
+
## Glossary [optional]
|
| 191 |
+
|
| 192 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 193 |
+
|
| 194 |
+
[More Information Needed]
|
| 195 |
+
|
| 196 |
+
## More Information [optional]
|
| 197 |
+
|
| 198 |
+
[More Information Needed]
|
| 199 |
+
|
| 200 |
+
## Model Card Authors [optional]
|
| 201 |
+
|
| 202 |
+
[More Information Needed]
|
| 203 |
+
|
| 204 |
+
## Model Card Contact
|
| 205 |
+
|
| 206 |
+
[More Information Needed]
|
| 207 |
+
### Framework versions
|
| 208 |
+
|
| 209 |
+
- PEFT 0.17.1
|
checkpoint-300/adapter_config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": null,
|
| 4 |
+
"base_model_name_or_path": "DeepSeek-Coder-V2-Lite-Instruct",
|
| 5 |
+
"bias": "none",
|
| 6 |
+
"corda_config": null,
|
| 7 |
+
"eva_config": null,
|
| 8 |
+
"exclude_modules": null,
|
| 9 |
+
"fan_in_fan_out": false,
|
| 10 |
+
"inference_mode": true,
|
| 11 |
+
"init_lora_weights": true,
|
| 12 |
+
"layer_replication": null,
|
| 13 |
+
"layers_pattern": null,
|
| 14 |
+
"layers_to_transform": null,
|
| 15 |
+
"loftq_config": {},
|
| 16 |
+
"lora_alpha": 16,
|
| 17 |
+
"lora_bias": false,
|
| 18 |
+
"lora_dropout": 0.1,
|
| 19 |
+
"megatron_config": null,
|
| 20 |
+
"megatron_core": "megatron.core",
|
| 21 |
+
"modules_to_save": null,
|
| 22 |
+
"peft_type": "LORA",
|
| 23 |
+
"qalora_group_size": 16,
|
| 24 |
+
"r": 8,
|
| 25 |
+
"rank_pattern": {},
|
| 26 |
+
"revision": null,
|
| 27 |
+
"target_modules": [
|
| 28 |
+
"q_proj",
|
| 29 |
+
"v_proj"
|
| 30 |
+
],
|
| 31 |
+
"target_parameters": null,
|
| 32 |
+
"task_type": "CAUSAL_LM",
|
| 33 |
+
"trainable_token_indices": null,
|
| 34 |
+
"use_dora": false,
|
| 35 |
+
"use_qalora": false,
|
| 36 |
+
"use_rslora": false
|
| 37 |
+
}
|
checkpoint-300/chat_template.jinja
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '
|
| 2 |
+
|
| 3 |
+
' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '
|
| 4 |
+
|
| 5 |
+
' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
checkpoint-300/special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|begin▁of▁sentence|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": true,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|end▁of▁sentence|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": true,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<|end▁of▁sentence|>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": true,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
checkpoint-300/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
checkpoint-300/tokenizer_config.json
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"add_prefix_space": null,
|
| 5 |
+
"added_tokens_decoder": {
|
| 6 |
+
"100000": {
|
| 7 |
+
"content": "<|begin▁of▁sentence|>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": true,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false,
|
| 12 |
+
"special": true
|
| 13 |
+
},
|
| 14 |
+
"100001": {
|
| 15 |
+
"content": "<|end▁of▁sentence|>",
|
| 16 |
+
"lstrip": false,
|
| 17 |
+
"normalized": true,
|
| 18 |
+
"rstrip": false,
|
| 19 |
+
"single_word": false,
|
| 20 |
+
"special": true
|
| 21 |
+
},
|
| 22 |
+
"100002": {
|
| 23 |
+
"content": "<|fim▁hole|>",
|
| 24 |
+
"lstrip": false,
|
| 25 |
+
"normalized": true,
|
| 26 |
+
"rstrip": false,
|
| 27 |
+
"single_word": false,
|
| 28 |
+
"special": false
|
| 29 |
+
},
|
| 30 |
+
"100003": {
|
| 31 |
+
"content": "<|fim▁begin|>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": true,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false,
|
| 36 |
+
"special": false
|
| 37 |
+
},
|
| 38 |
+
"100004": {
|
| 39 |
+
"content": "<|fim▁end|>",
|
| 40 |
+
"lstrip": false,
|
| 41 |
+
"normalized": true,
|
| 42 |
+
"rstrip": false,
|
| 43 |
+
"single_word": false,
|
| 44 |
+
"special": false
|
| 45 |
+
},
|
| 46 |
+
"100005": {
|
| 47 |
+
"content": "<|completion|>",
|
| 48 |
+
"lstrip": false,
|
| 49 |
+
"normalized": true,
|
| 50 |
+
"rstrip": false,
|
| 51 |
+
"single_word": false,
|
| 52 |
+
"special": false
|
| 53 |
+
},
|
| 54 |
+
"100006": {
|
| 55 |
+
"content": "<|User|>",
|
| 56 |
+
"lstrip": false,
|
| 57 |
+
"normalized": true,
|
| 58 |
+
"rstrip": false,
|
| 59 |
+
"single_word": false,
|
| 60 |
+
"special": false
|
| 61 |
+
},
|
| 62 |
+
"100007": {
|
| 63 |
+
"content": "<|Assistant|>",
|
| 64 |
+
"lstrip": false,
|
| 65 |
+
"normalized": true,
|
| 66 |
+
"rstrip": false,
|
| 67 |
+
"single_word": false,
|
| 68 |
+
"special": false
|
| 69 |
+
},
|
| 70 |
+
"100008": {
|
| 71 |
+
"content": "<|EOT|>",
|
| 72 |
+
"lstrip": false,
|
| 73 |
+
"normalized": true,
|
| 74 |
+
"rstrip": false,
|
| 75 |
+
"single_word": false,
|
| 76 |
+
"special": true
|
| 77 |
+
},
|
| 78 |
+
"100009": {
|
| 79 |
+
"content": "<|tool▁calls▁begin|>",
|
| 80 |
+
"lstrip": false,
|
| 81 |
+
"normalized": true,
|
| 82 |
+
"rstrip": false,
|
| 83 |
+
"single_word": false,
|
| 84 |
+
"special": false
|
| 85 |
+
},
|
| 86 |
+
"100010": {
|
| 87 |
+
"content": "<|tool▁calls▁end|>",
|
| 88 |
+
"lstrip": false,
|
| 89 |
+
"normalized": true,
|
| 90 |
+
"rstrip": false,
|
| 91 |
+
"single_word": false,
|
| 92 |
+
"special": false
|
| 93 |
+
},
|
| 94 |
+
"100011": {
|
| 95 |
+
"content": "<|tool▁call▁begin|>",
|
| 96 |
+
"lstrip": false,
|
| 97 |
+
"normalized": true,
|
| 98 |
+
"rstrip": false,
|
| 99 |
+
"single_word": false,
|
| 100 |
+
"special": false
|
| 101 |
+
},
|
| 102 |
+
"100012": {
|
| 103 |
+
"content": "<|tool▁call▁end|>",
|
| 104 |
+
"lstrip": false,
|
| 105 |
+
"normalized": true,
|
| 106 |
+
"rstrip": false,
|
| 107 |
+
"single_word": false,
|
| 108 |
+
"special": false
|
| 109 |
+
},
|
| 110 |
+
"100013": {
|
| 111 |
+
"content": "<|tool▁outputs▁begin|>",
|
| 112 |
+
"lstrip": false,
|
| 113 |
+
"normalized": true,
|
| 114 |
+
"rstrip": false,
|
| 115 |
+
"single_word": false,
|
| 116 |
+
"special": false
|
| 117 |
+
},
|
| 118 |
+
"100014": {
|
| 119 |
+
"content": "<|tool▁outputs▁end|>",
|
| 120 |
+
"lstrip": false,
|
| 121 |
+
"normalized": true,
|
| 122 |
+
"rstrip": false,
|
| 123 |
+
"single_word": false,
|
| 124 |
+
"special": false
|
| 125 |
+
},
|
| 126 |
+
"100015": {
|
| 127 |
+
"content": "<|tool▁output▁begin|>",
|
| 128 |
+
"lstrip": false,
|
| 129 |
+
"normalized": true,
|
| 130 |
+
"rstrip": false,
|
| 131 |
+
"single_word": false,
|
| 132 |
+
"special": false
|
| 133 |
+
},
|
| 134 |
+
"100016": {
|
| 135 |
+
"content": "<|tool▁output▁end|>",
|
| 136 |
+
"lstrip": false,
|
| 137 |
+
"normalized": true,
|
| 138 |
+
"rstrip": false,
|
| 139 |
+
"single_word": false,
|
| 140 |
+
"special": false
|
| 141 |
+
},
|
| 142 |
+
"100017": {
|
| 143 |
+
"content": "<|tool▁sep|>",
|
| 144 |
+
"lstrip": false,
|
| 145 |
+
"normalized": true,
|
| 146 |
+
"rstrip": false,
|
| 147 |
+
"single_word": false,
|
| 148 |
+
"special": false
|
| 149 |
+
}
|
| 150 |
+
},
|
| 151 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
| 152 |
+
"clean_up_tokenization_spaces": false,
|
| 153 |
+
"eos_token": "<|end▁of▁sentence|>",
|
| 154 |
+
"extra_special_tokens": {},
|
| 155 |
+
"legacy": true,
|
| 156 |
+
"model_max_length": 16384,
|
| 157 |
+
"pad_token": "<|end▁of▁sentence|>",
|
| 158 |
+
"sp_model_kwargs": {},
|
| 159 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
| 160 |
+
"unk_token": null,
|
| 161 |
+
"use_default_system_prompt": false
|
| 162 |
+
}
|
checkpoint-300/trainer_state.json
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 100.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 300,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"entropy": 1.9060055136680603,
|
| 14 |
+
"epoch": 3.3333333333333335,
|
| 15 |
+
"grad_norm": 1.0164649486541748,
|
| 16 |
+
"learning_rate": 1.5e-05,
|
| 17 |
+
"loss": 4.1011,
|
| 18 |
+
"mean_token_accuracy": 0.4009168431162834,
|
| 19 |
+
"num_tokens": 5512.0,
|
| 20 |
+
"step": 10
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"entropy": 1.9487085342407227,
|
| 24 |
+
"epoch": 6.666666666666667,
|
| 25 |
+
"grad_norm": 0.9628961682319641,
|
| 26 |
+
"learning_rate": 3.1666666666666666e-05,
|
| 27 |
+
"loss": 4.1923,
|
| 28 |
+
"mean_token_accuracy": 0.39442635476589205,
|
| 29 |
+
"num_tokens": 10326.0,
|
| 30 |
+
"step": 20
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"entropy": 1.8993895709514619,
|
| 34 |
+
"epoch": 10.0,
|
| 35 |
+
"grad_norm": 1.177027702331543,
|
| 36 |
+
"learning_rate": 4.8333333333333334e-05,
|
| 37 |
+
"loss": 4.0334,
|
| 38 |
+
"mean_token_accuracy": 0.40877673774957657,
|
| 39 |
+
"num_tokens": 15462.0,
|
| 40 |
+
"step": 30
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"entropy": 1.9950154840946197,
|
| 44 |
+
"epoch": 13.333333333333334,
|
| 45 |
+
"grad_norm": 1.436251163482666,
|
| 46 |
+
"learning_rate": 4.9863047384206835e-05,
|
| 47 |
+
"loss": 3.9342,
|
| 48 |
+
"mean_token_accuracy": 0.40931957215070724,
|
| 49 |
+
"num_tokens": 20681.0,
|
| 50 |
+
"step": 40
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"entropy": 2.067208158969879,
|
| 54 |
+
"epoch": 16.666666666666668,
|
| 55 |
+
"grad_norm": 1.078131079673767,
|
| 56 |
+
"learning_rate": 4.939155700460536e-05,
|
| 57 |
+
"loss": 3.7698,
|
| 58 |
+
"mean_token_accuracy": 0.42098456621170044,
|
| 59 |
+
"num_tokens": 26109.0,
|
| 60 |
+
"step": 50
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"entropy": 2.193948692083359,
|
| 64 |
+
"epoch": 20.0,
|
| 65 |
+
"grad_norm": 1.1934932470321655,
|
| 66 |
+
"learning_rate": 4.859021265983959e-05,
|
| 67 |
+
"loss": 3.6115,
|
| 68 |
+
"mean_token_accuracy": 0.43236732184886933,
|
| 69 |
+
"num_tokens": 31244.0,
|
| 70 |
+
"step": 60
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"entropy": 2.4151065587997436,
|
| 74 |
+
"epoch": 23.333333333333332,
|
| 75 |
+
"grad_norm": 0.8595532774925232,
|
| 76 |
+
"learning_rate": 4.7469851157479177e-05,
|
| 77 |
+
"loss": 3.5401,
|
| 78 |
+
"mean_token_accuracy": 0.42654525190591813,
|
| 79 |
+
"num_tokens": 36738.0,
|
| 80 |
+
"step": 70
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"entropy": 2.4695091366767885,
|
| 84 |
+
"epoch": 26.666666666666668,
|
| 85 |
+
"grad_norm": 0.9981549978256226,
|
| 86 |
+
"learning_rate": 4.604562346488144e-05,
|
| 87 |
+
"loss": 3.3173,
|
| 88 |
+
"mean_token_accuracy": 0.4566218167543411,
|
| 89 |
+
"num_tokens": 41886.0,
|
| 90 |
+
"step": 80
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"entropy": 2.4938253283500673,
|
| 94 |
+
"epoch": 30.0,
|
| 95 |
+
"grad_norm": 0.5646995902061462,
|
| 96 |
+
"learning_rate": 4.43367898183491e-05,
|
| 97 |
+
"loss": 3.1822,
|
| 98 |
+
"mean_token_accuracy": 0.4696041285991669,
|
| 99 |
+
"num_tokens": 46983.0,
|
| 100 |
+
"step": 90
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"entropy": 2.564500260353088,
|
| 104 |
+
"epoch": 33.333333333333336,
|
| 105 |
+
"grad_norm": 0.8602616786956787,
|
| 106 |
+
"learning_rate": 4.2366459261474933e-05,
|
| 107 |
+
"loss": 3.1409,
|
| 108 |
+
"mean_token_accuracy": 0.47821263819932935,
|
| 109 |
+
"num_tokens": 52150.0,
|
| 110 |
+
"step": 100
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"entropy": 2.5386017203330993,
|
| 114 |
+
"epoch": 36.666666666666664,
|
| 115 |
+
"grad_norm": 0.7394922971725464,
|
| 116 |
+
"learning_rate": 4.0161277134970345e-05,
|
| 117 |
+
"loss": 2.9888,
|
| 118 |
+
"mean_token_accuracy": 0.49289675503969194,
|
| 119 |
+
"num_tokens": 57240.0,
|
| 120 |
+
"step": 110
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"entropy": 2.5600393176078797,
|
| 124 |
+
"epoch": 40.0,
|
| 125 |
+
"grad_norm": 0.6606329083442688,
|
| 126 |
+
"learning_rate": 3.775106474414188e-05,
|
| 127 |
+
"loss": 2.9445,
|
| 128 |
+
"mean_token_accuracy": 0.5016584262251854,
|
| 129 |
+
"num_tokens": 62806.0,
|
| 130 |
+
"step": 120
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"entropy": 2.547697913646698,
|
| 134 |
+
"epoch": 43.333333333333336,
|
| 135 |
+
"grad_norm": 0.8845142126083374,
|
| 136 |
+
"learning_rate": 3.516841607689501e-05,
|
| 137 |
+
"loss": 2.9015,
|
| 138 |
+
"mean_token_accuracy": 0.5097966089844703,
|
| 139 |
+
"num_tokens": 67877.0,
|
| 140 |
+
"step": 130
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"entropy": 2.5584489583969114,
|
| 144 |
+
"epoch": 46.666666666666664,
|
| 145 |
+
"grad_norm": 0.8559042811393738,
|
| 146 |
+
"learning_rate": 3.244825702596205e-05,
|
| 147 |
+
"loss": 2.9204,
|
| 148 |
+
"mean_token_accuracy": 0.503237409889698,
|
| 149 |
+
"num_tokens": 73030.0,
|
| 150 |
+
"step": 140
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"entropy": 2.479199802875519,
|
| 154 |
+
"epoch": 50.0,
|
| 155 |
+
"grad_norm": 0.9662401080131531,
|
| 156 |
+
"learning_rate": 2.9627373076117863e-05,
|
| 157 |
+
"loss": 2.7848,
|
| 158 |
+
"mean_token_accuracy": 0.5199230208992958,
|
| 159 |
+
"num_tokens": 78133.0,
|
| 160 |
+
"step": 150
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"entropy": 2.451095724105835,
|
| 164 |
+
"epoch": 53.333333333333336,
|
| 165 |
+
"grad_norm": 0.7248209714889526,
|
| 166 |
+
"learning_rate": 2.674391184360313e-05,
|
| 167 |
+
"loss": 2.72,
|
| 168 |
+
"mean_token_accuracy": 0.530137126147747,
|
| 169 |
+
"num_tokens": 83587.0,
|
| 170 |
+
"step": 160
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"entropy": 2.4100263833999636,
|
| 174 |
+
"epoch": 56.666666666666664,
|
| 175 |
+
"grad_norm": 0.8213902115821838,
|
| 176 |
+
"learning_rate": 2.3836867195056335e-05,
|
| 177 |
+
"loss": 2.6899,
|
| 178 |
+
"mean_token_accuracy": 0.5364036962389946,
|
| 179 |
+
"num_tokens": 88745.0,
|
| 180 |
+
"step": 170
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"entropy": 2.3743161976337435,
|
| 184 |
+
"epoch": 60.0,
|
| 185 |
+
"grad_norm": 0.9216499924659729,
|
| 186 |
+
"learning_rate": 2.0945551922360818e-05,
|
| 187 |
+
"loss": 2.6164,
|
| 188 |
+
"mean_token_accuracy": 0.5464533418416977,
|
| 189 |
+
"num_tokens": 93971.0,
|
| 190 |
+
"step": 180
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"entropy": 2.3309614181518556,
|
| 194 |
+
"epoch": 63.333333333333336,
|
| 195 |
+
"grad_norm": 0.9028099179267883,
|
| 196 |
+
"learning_rate": 1.8109066104575023e-05,
|
| 197 |
+
"loss": 2.577,
|
| 198 |
+
"mean_token_accuracy": 0.5494851708412171,
|
| 199 |
+
"num_tokens": 99176.0,
|
| 200 |
+
"step": 190
|
| 201 |
+
},
|
| 202 |
+
{
|
| 203 |
+
"entropy": 2.3660804867744445,
|
| 204 |
+
"epoch": 66.66666666666667,
|
| 205 |
+
"grad_norm": 1.1050912141799927,
|
| 206 |
+
"learning_rate": 1.5365768346438797e-05,
|
| 207 |
+
"loss": 2.6015,
|
| 208 |
+
"mean_token_accuracy": 0.5429237529635429,
|
| 209 |
+
"num_tokens": 104369.0,
|
| 210 |
+
"step": 200
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"entropy": 2.2412913620471953,
|
| 214 |
+
"epoch": 70.0,
|
| 215 |
+
"grad_norm": 1.1248013973236084,
|
| 216 |
+
"learning_rate": 1.2752757044047827e-05,
|
| 217 |
+
"loss": 2.4471,
|
| 218 |
+
"mean_token_accuracy": 0.5652078241109848,
|
| 219 |
+
"num_tokens": 109867.0,
|
| 220 |
+
"step": 210
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"entropy": 2.2687363147735597,
|
| 224 |
+
"epoch": 73.33333333333333,
|
| 225 |
+
"grad_norm": 0.8138008117675781,
|
| 226 |
+
"learning_rate": 1.0305368692688174e-05,
|
| 227 |
+
"loss": 2.4754,
|
| 228 |
+
"mean_token_accuracy": 0.5577909976243973,
|
| 229 |
+
"num_tokens": 115316.0,
|
| 230 |
+
"step": 220
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"entropy": 2.2360614061355593,
|
| 234 |
+
"epoch": 76.66666666666667,
|
| 235 |
+
"grad_norm": 0.9668932557106018,
|
| 236 |
+
"learning_rate": 8.056700021356694e-06,
|
| 237 |
+
"loss": 2.4623,
|
| 238 |
+
"mean_token_accuracy": 0.5630308628082276,
|
| 239 |
+
"num_tokens": 120487.0,
|
| 240 |
+
"step": 230
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"entropy": 2.28078556060791,
|
| 244 |
+
"epoch": 80.0,
|
| 245 |
+
"grad_norm": 0.9901016354560852,
|
| 246 |
+
"learning_rate": 6.037160416278278e-06,
|
| 247 |
+
"loss": 2.5002,
|
| 248 |
+
"mean_token_accuracy": 0.5567112416028976,
|
| 249 |
+
"num_tokens": 125629.0,
|
| 250 |
+
"step": 240
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"entropy": 2.2194084882736207,
|
| 254 |
+
"epoch": 83.33333333333333,
|
| 255 |
+
"grad_norm": 1.047966480255127,
|
| 256 |
+
"learning_rate": 4.274060686123959e-06,
|
| 257 |
+
"loss": 2.418,
|
| 258 |
+
"mean_token_accuracy": 0.5643551826477051,
|
| 259 |
+
"num_tokens": 130811.0,
|
| 260 |
+
"step": 250
|
| 261 |
+
},
|
| 262 |
+
{
|
| 263 |
+
"entropy": 2.2408297181129457,
|
| 264 |
+
"epoch": 86.66666666666667,
|
| 265 |
+
"grad_norm": 1.1455246210098267,
|
| 266 |
+
"learning_rate": 2.7912437301749026e-06,
|
| 267 |
+
"loss": 2.4294,
|
| 268 |
+
"mean_token_accuracy": 0.5679019063711166,
|
| 269 |
+
"num_tokens": 135921.0,
|
| 270 |
+
"step": 260
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"entropy": 2.2160379528999328,
|
| 274 |
+
"epoch": 90.0,
|
| 275 |
+
"grad_norm": 1.1439515352249146,
|
| 276 |
+
"learning_rate": 1.6087621040117157e-06,
|
| 277 |
+
"loss": 2.4361,
|
| 278 |
+
"mean_token_accuracy": 0.5633732363581657,
|
| 279 |
+
"num_tokens": 140722.0,
|
| 280 |
+
"step": 270
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
"entropy": 2.277903026342392,
|
| 284 |
+
"epoch": 93.33333333333333,
|
| 285 |
+
"grad_norm": 1.191327452659607,
|
| 286 |
+
"learning_rate": 7.426068431000882e-07,
|
| 287 |
+
"loss": 2.4947,
|
| 288 |
+
"mean_token_accuracy": 0.5539214983582497,
|
| 289 |
+
"num_tokens": 145887.0,
|
| 290 |
+
"step": 280
|
| 291 |
+
},
|
| 292 |
+
{
|
| 293 |
+
"entropy": 2.1880038678646088,
|
| 294 |
+
"epoch": 96.66666666666667,
|
| 295 |
+
"grad_norm": 1.1344318389892578,
|
| 296 |
+
"learning_rate": 2.0449121146845774e-07,
|
| 297 |
+
"loss": 2.3935,
|
| 298 |
+
"mean_token_accuracy": 0.5718189179897308,
|
| 299 |
+
"num_tokens": 150980.0,
|
| 300 |
+
"step": 290
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"entropy": 2.2173574447631834,
|
| 304 |
+
"epoch": 100.0,
|
| 305 |
+
"grad_norm": 1.0592862367630005,
|
| 306 |
+
"learning_rate": 1.692299905944883e-09,
|
| 307 |
+
"loss": 2.4204,
|
| 308 |
+
"mean_token_accuracy": 0.5628041237592697,
|
| 309 |
+
"num_tokens": 156525.0,
|
| 310 |
+
"step": 300
|
| 311 |
+
}
|
| 312 |
+
],
|
| 313 |
+
"logging_steps": 10,
|
| 314 |
+
"max_steps": 300,
|
| 315 |
+
"num_input_tokens_seen": 0,
|
| 316 |
+
"num_train_epochs": 100,
|
| 317 |
+
"save_steps": 50,
|
| 318 |
+
"stateful_callbacks": {
|
| 319 |
+
"TrainerControl": {
|
| 320 |
+
"args": {
|
| 321 |
+
"should_epoch_stop": false,
|
| 322 |
+
"should_evaluate": false,
|
| 323 |
+
"should_log": false,
|
| 324 |
+
"should_save": true,
|
| 325 |
+
"should_training_stop": true
|
| 326 |
+
},
|
| 327 |
+
"attributes": {}
|
| 328 |
+
}
|
| 329 |
+
},
|
| 330 |
+
"total_flos": 1.8686345743478784e+16,
|
| 331 |
+
"train_batch_size": 2,
|
| 332 |
+
"trial_name": null,
|
| 333 |
+
"trial_params": null
|
| 334 |
+
}
|
checkpoint-300/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0732842102da7bf8db229d843550c94a8d413ab0b06dfc753dfe4e84b41a97c
|
| 3 |
+
size 6161
|
config.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"DeepseekV2ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
|
| 8 |
+
"aux_loss_alpha": 0.001,
|
| 9 |
+
"bos_token_id": 100000,
|
| 10 |
+
"eos_token_id": 100001,
|
| 11 |
+
"first_k_dense_replace": 1,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 2048,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 10944,
|
| 16 |
+
"kv_lora_rank": 512,
|
| 17 |
+
"max_position_embeddings": 163840,
|
| 18 |
+
"model_type": "causal_lm",
|
| 19 |
+
"moe_intermediate_size": 1408,
|
| 20 |
+
"moe_layer_freq": 1,
|
| 21 |
+
"n_group": 1,
|
| 22 |
+
"n_routed_experts": 64,
|
| 23 |
+
"n_shared_experts": 2,
|
| 24 |
+
"norm_topk_prob": false,
|
| 25 |
+
"num_attention_heads": 16,
|
| 26 |
+
"num_experts_per_tok": 6,
|
| 27 |
+
"num_hidden_layers": 27,
|
| 28 |
+
"num_key_value_heads": 16,
|
| 29 |
+
"pretraining_tp": 1,
|
| 30 |
+
"q_lora_rank": null,
|
| 31 |
+
"qk_nope_head_dim": 128,
|
| 32 |
+
"qk_rope_head_dim": 64,
|
| 33 |
+
"rms_norm_eps": 1e-06,
|
| 34 |
+
"rope_scaling": {
|
| 35 |
+
"beta_fast": 32,
|
| 36 |
+
"beta_slow": 1,
|
| 37 |
+
"factor": 40,
|
| 38 |
+
"mscale": 0.707,
|
| 39 |
+
"mscale_all_dim": 0.707,
|
| 40 |
+
"original_max_position_embeddings": 4096,
|
| 41 |
+
"type": "yarn"
|
| 42 |
+
},
|
| 43 |
+
"rope_theta": 10000,
|
| 44 |
+
"routed_scaling_factor": 1.0,
|
| 45 |
+
"scoring_func": "softmax",
|
| 46 |
+
"seq_aux": true,
|
| 47 |
+
"tie_word_embeddings": false,
|
| 48 |
+
"topk_group": 1,
|
| 49 |
+
"topk_method": "greedy",
|
| 50 |
+
"torch_dtype": "bfloat16",
|
| 51 |
+
"transformers_version": "4.39.3",
|
| 52 |
+
"use_cache": true,
|
| 53 |
+
"v_head_dim": 128,
|
| 54 |
+
"vocab_size": 102400
|
| 55 |
+
}
|
configuration_deepseek.py
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 2 |
+
from transformers.utils import logging
|
| 3 |
+
|
| 4 |
+
logger = logging.get_logger(__name__)
|
| 5 |
+
|
| 6 |
+
DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
| 7 |
+
class DeepseekV2Config(PretrainedConfig):
|
| 8 |
+
r"""
|
| 9 |
+
This is the configuration class to store the configuration of a [`DeepseekV2Model`]. It is used to instantiate an DeepSeek
|
| 10 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
| 11 |
+
defaults will yield a similar configuration to that of the DeepSeek-V2.
|
| 12 |
+
|
| 13 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 14 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Args:
|
| 18 |
+
vocab_size (`int`, *optional*, defaults to 102400):
|
| 19 |
+
Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
|
| 20 |
+
`inputs_ids` passed when calling [`DeepseekV2Model`]
|
| 21 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 22 |
+
Dimension of the hidden representations.
|
| 23 |
+
intermediate_size (`int`, *optional*, defaults to 11008):
|
| 24 |
+
Dimension of the MLP representations.
|
| 25 |
+
moe_intermediate_size (`int`, *optional*, defaults to 1407):
|
| 26 |
+
Dimension of the MoE representations.
|
| 27 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 28 |
+
Number of hidden layers in the Transformer decoder.
|
| 29 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 30 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
| 31 |
+
n_shared_experts (`int`, *optional*, defaults to None):
|
| 32 |
+
Number of shared experts, None means dense model.
|
| 33 |
+
n_routed_experts (`int`, *optional*, defaults to None):
|
| 34 |
+
Number of routed experts, None means dense model.
|
| 35 |
+
routed_scaling_factor (`float`, *optional*, defaults to 1.0):
|
| 36 |
+
Scaling factor or routed experts.
|
| 37 |
+
topk_method (`str`, *optional*, defaults to `gready`):
|
| 38 |
+
Topk method used in routed gate.
|
| 39 |
+
n_group (`int`, *optional*, defaults to None):
|
| 40 |
+
Number of groups for routed experts.
|
| 41 |
+
topk_group (`int`, *optional*, defaults to None):
|
| 42 |
+
Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
|
| 43 |
+
num_experts_per_tok (`int`, *optional*, defaults to None):
|
| 44 |
+
Number of selected experts, None means dense model.
|
| 45 |
+
moe_layer_freq (`int`, *optional*, defaults to 1):
|
| 46 |
+
The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
|
| 47 |
+
first_k_dense_replace (`int`, *optional*, defaults to 0):
|
| 48 |
+
Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
|
| 49 |
+
\--k dense layers--/
|
| 50 |
+
norm_topk_prob (`bool`, *optional*, defaults to False):
|
| 51 |
+
Whether to normalize the weights of the routed experts.
|
| 52 |
+
scoring_func (`str`, *optional*, defaults to 'softmax'):
|
| 53 |
+
Method of computing expert weights.
|
| 54 |
+
aux_loss_alpha (`float`, *optional*, defaults to 0.001):
|
| 55 |
+
Auxiliary loss weight coefficient.
|
| 56 |
+
seq_aux = (`bool`, *optional*, defaults to True):
|
| 57 |
+
Whether to compute the auxiliary loss for each individual sample.
|
| 58 |
+
num_key_value_heads (`int`, *optional*):
|
| 59 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 60 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 61 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 62 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 63 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
| 64 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
| 65 |
+
`num_attention_heads`.
|
| 66 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 67 |
+
The non-linear activation function (function or string) in the decoder.
|
| 68 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
| 69 |
+
The maximum sequence length that this model might ever be used with.
|
| 70 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 71 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 72 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 73 |
+
The epsilon used by the rms normalization layers.
|
| 74 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 75 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 76 |
+
relevant if `config.is_decoder=True`.
|
| 77 |
+
pad_token_id (`int`, *optional*):
|
| 78 |
+
Padding token id.
|
| 79 |
+
bos_token_id (`int`, *optional*, defaults to 1):
|
| 80 |
+
Beginning of stream token id.
|
| 81 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
| 82 |
+
End of stream token id.
|
| 83 |
+
pretraining_tp (`int`, *optional*, defaults to 1):
|
| 84 |
+
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
|
| 85 |
+
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
| 86 |
+
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
| 87 |
+
issue](https://github.com/pytorch/pytorch/issues/76232).
|
| 88 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 89 |
+
Whether to tie weight embeddings
|
| 90 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
| 91 |
+
The base period of the RoPE embeddings.
|
| 92 |
+
rope_scaling (`Dict`, *optional*):
|
| 93 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
|
| 94 |
+
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
|
| 95 |
+
`{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
| 96 |
+
`max_position_embeddings` to the expected new maximum.
|
| 97 |
+
attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
|
| 98 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
| 99 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 100 |
+
The dropout ratio for the attention probabilities.
|
| 101 |
+
|
| 102 |
+
```python
|
| 103 |
+
>>> from transformers import DeepseekV2Model, DeepseekV2Config
|
| 104 |
+
|
| 105 |
+
>>> # Initializing a Deepseek-V2 style configuration
|
| 106 |
+
>>> configuration = DeepseekV2Config()
|
| 107 |
+
|
| 108 |
+
>>> # Accessing the model configuration
|
| 109 |
+
>>> configuration = model.config
|
| 110 |
+
```"""
|
| 111 |
+
|
| 112 |
+
model_type = "deepseek_v2"
|
| 113 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 114 |
+
|
| 115 |
+
def __init__(
|
| 116 |
+
self,
|
| 117 |
+
vocab_size=102400,
|
| 118 |
+
hidden_size=4096,
|
| 119 |
+
intermediate_size=11008,
|
| 120 |
+
moe_intermediate_size = 1407,
|
| 121 |
+
num_hidden_layers=30,
|
| 122 |
+
num_attention_heads=32,
|
| 123 |
+
num_key_value_heads=32,
|
| 124 |
+
n_shared_experts = None,
|
| 125 |
+
n_routed_experts = None,
|
| 126 |
+
ep_size = 1,
|
| 127 |
+
routed_scaling_factor = 1.0,
|
| 128 |
+
kv_lora_rank = 512,
|
| 129 |
+
q_lora_rank = 1536,
|
| 130 |
+
qk_rope_head_dim = 64,
|
| 131 |
+
v_head_dim = 128,
|
| 132 |
+
qk_nope_head_dim = 128,
|
| 133 |
+
topk_method = 'gready',
|
| 134 |
+
n_group = None,
|
| 135 |
+
topk_group = None,
|
| 136 |
+
num_experts_per_tok = None,
|
| 137 |
+
moe_layer_freq = 1,
|
| 138 |
+
first_k_dense_replace = 0,
|
| 139 |
+
norm_topk_prob = False,
|
| 140 |
+
scoring_func = 'softmax',
|
| 141 |
+
aux_loss_alpha = 0.001,
|
| 142 |
+
seq_aux = True,
|
| 143 |
+
hidden_act="silu",
|
| 144 |
+
max_position_embeddings=2048,
|
| 145 |
+
initializer_range=0.02,
|
| 146 |
+
rms_norm_eps=1e-6,
|
| 147 |
+
use_cache=True,
|
| 148 |
+
pad_token_id=None,
|
| 149 |
+
bos_token_id=100000,
|
| 150 |
+
eos_token_id=100001,
|
| 151 |
+
pretraining_tp=1,
|
| 152 |
+
tie_word_embeddings=False,
|
| 153 |
+
rope_theta=10000.0,
|
| 154 |
+
rope_scaling=None,
|
| 155 |
+
attention_bias=False,
|
| 156 |
+
attention_dropout=0.0,
|
| 157 |
+
**kwargs,
|
| 158 |
+
):
|
| 159 |
+
self.vocab_size = vocab_size
|
| 160 |
+
self.max_position_embeddings = max_position_embeddings
|
| 161 |
+
self.hidden_size = hidden_size
|
| 162 |
+
self.intermediate_size = intermediate_size
|
| 163 |
+
self.moe_intermediate_size = moe_intermediate_size
|
| 164 |
+
self.num_hidden_layers = num_hidden_layers
|
| 165 |
+
self.num_attention_heads = num_attention_heads
|
| 166 |
+
self.n_shared_experts = n_shared_experts
|
| 167 |
+
self.n_routed_experts = n_routed_experts
|
| 168 |
+
self.ep_size = ep_size
|
| 169 |
+
self.routed_scaling_factor = routed_scaling_factor
|
| 170 |
+
self.kv_lora_rank = kv_lora_rank
|
| 171 |
+
self.q_lora_rank = q_lora_rank
|
| 172 |
+
self.qk_rope_head_dim = qk_rope_head_dim
|
| 173 |
+
self.v_head_dim = v_head_dim
|
| 174 |
+
self.qk_nope_head_dim = qk_nope_head_dim
|
| 175 |
+
self.topk_method = topk_method
|
| 176 |
+
self.n_group = n_group
|
| 177 |
+
self.topk_group = topk_group
|
| 178 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 179 |
+
self.moe_layer_freq = moe_layer_freq
|
| 180 |
+
self.first_k_dense_replace = first_k_dense_replace
|
| 181 |
+
self.norm_topk_prob = norm_topk_prob
|
| 182 |
+
self.scoring_func = scoring_func
|
| 183 |
+
self.aux_loss_alpha = aux_loss_alpha
|
| 184 |
+
self.seq_aux = seq_aux
|
| 185 |
+
# for backward compatibility
|
| 186 |
+
if num_key_value_heads is None:
|
| 187 |
+
num_key_value_heads = num_attention_heads
|
| 188 |
+
|
| 189 |
+
self.num_key_value_heads = num_key_value_heads
|
| 190 |
+
self.hidden_act = hidden_act
|
| 191 |
+
self.initializer_range = initializer_range
|
| 192 |
+
self.rms_norm_eps = rms_norm_eps
|
| 193 |
+
self.pretraining_tp = pretraining_tp
|
| 194 |
+
self.use_cache = use_cache
|
| 195 |
+
self.rope_theta = rope_theta
|
| 196 |
+
self.rope_scaling = rope_scaling
|
| 197 |
+
self.attention_bias = attention_bias
|
| 198 |
+
self.attention_dropout = attention_dropout
|
| 199 |
+
|
| 200 |
+
super().__init__(
|
| 201 |
+
pad_token_id=pad_token_id,
|
| 202 |
+
bos_token_id=bos_token_id,
|
| 203 |
+
eos_token_id=eos_token_id,
|
| 204 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 205 |
+
**kwargs,
|
| 206 |
+
)
|
generation_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 100000,
|
| 4 |
+
"eos_token_id": 100001,
|
| 5 |
+
"do_sample": true,
|
| 6 |
+
"temperature": 0.3,
|
| 7 |
+
"top_p": 0.95,
|
| 8 |
+
"transformers_version": "4.39.3"
|
| 9 |
+
}
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modeling_deepseek.py
ADDED
|
@@ -0,0 +1,1924 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2023 DeepSeek-AI and The HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
| 5 |
+
# and OPT implementations in this library. It has been modified from its
|
| 6 |
+
# original forms to accommodate minor architectural differences compared
|
| 7 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
| 8 |
+
#
|
| 9 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 10 |
+
# you may not use this file except in compliance with the License.
|
| 11 |
+
# You may obtain a copy of the License at
|
| 12 |
+
#
|
| 13 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 14 |
+
#
|
| 15 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 16 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 17 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 18 |
+
# See the License for the specific language governing permissions and
|
| 19 |
+
# limitations under the License.
|
| 20 |
+
""" PyTorch DeepSeek model."""
|
| 21 |
+
import math
|
| 22 |
+
import warnings
|
| 23 |
+
from typing import List, Optional, Tuple, Union
|
| 24 |
+
|
| 25 |
+
import torch
|
| 26 |
+
import torch.nn.functional as F
|
| 27 |
+
import torch.utils.checkpoint
|
| 28 |
+
from torch import nn
|
| 29 |
+
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
|
| 30 |
+
|
| 31 |
+
from transformers.activations import ACT2FN
|
| 32 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 33 |
+
from transformers.modeling_attn_mask_utils import (
|
| 34 |
+
AttentionMaskConverter,
|
| 35 |
+
_prepare_4d_attention_mask,
|
| 36 |
+
_prepare_4d_causal_attention_mask,
|
| 37 |
+
)
|
| 38 |
+
from transformers.modeling_outputs import (
|
| 39 |
+
BaseModelOutputWithPast,
|
| 40 |
+
CausalLMOutputWithPast,
|
| 41 |
+
SequenceClassifierOutputWithPast,
|
| 42 |
+
)
|
| 43 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 44 |
+
from transformers.pytorch_utils import (
|
| 45 |
+
ALL_LAYERNORM_LAYERS,
|
| 46 |
+
is_torch_greater_or_equal_than_1_13,
|
| 47 |
+
)
|
| 48 |
+
from transformers.utils import (
|
| 49 |
+
add_start_docstrings,
|
| 50 |
+
add_start_docstrings_to_model_forward,
|
| 51 |
+
is_flash_attn_2_available,
|
| 52 |
+
is_flash_attn_greater_or_equal_2_10,
|
| 53 |
+
logging,
|
| 54 |
+
replace_return_docstrings,
|
| 55 |
+
)
|
| 56 |
+
from transformers.utils.import_utils import is_torch_fx_available
|
| 57 |
+
from configuration_deepseek import DeepseekV2Config
|
| 58 |
+
import torch.distributed as dist
|
| 59 |
+
import numpy as np
|
| 60 |
+
|
| 61 |
+
if is_flash_attn_2_available():
|
| 62 |
+
from flash_attn import flash_attn_func, flash_attn_varlen_func
|
| 63 |
+
from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# This makes `_prepare_4d_causal_attention_mask` a leaf function in the FX graph.
|
| 67 |
+
# It means that the function will not be traced through and simply appear as a node in the graph.
|
| 68 |
+
if is_torch_fx_available():
|
| 69 |
+
if not is_torch_greater_or_equal_than_1_13:
|
| 70 |
+
import torch.fx
|
| 71 |
+
|
| 72 |
+
_prepare_4d_causal_attention_mask = torch.fx.wrap(_prepare_4d_causal_attention_mask)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
logger = logging.get_logger(__name__)
|
| 76 |
+
|
| 77 |
+
_CONFIG_FOR_DOC = "DeepseekV2Config"
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def _get_unpad_data(attention_mask):
|
| 81 |
+
seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
|
| 82 |
+
indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
|
| 83 |
+
max_seqlen_in_batch = seqlens_in_batch.max().item()
|
| 84 |
+
cu_seqlens = F.pad(
|
| 85 |
+
torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0)
|
| 86 |
+
)
|
| 87 |
+
return (
|
| 88 |
+
indices,
|
| 89 |
+
cu_seqlens,
|
| 90 |
+
max_seqlen_in_batch,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class DeepseekV2RMSNorm(nn.Module):
|
| 95 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 96 |
+
"""
|
| 97 |
+
DeepseekV2RMSNorm is equivalent to T5LayerNorm
|
| 98 |
+
"""
|
| 99 |
+
super().__init__()
|
| 100 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 101 |
+
self.variance_epsilon = eps
|
| 102 |
+
|
| 103 |
+
def forward(self, hidden_states):
|
| 104 |
+
input_dtype = hidden_states.dtype
|
| 105 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 106 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 107 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 108 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
ALL_LAYERNORM_LAYERS.append(DeepseekV2RMSNorm)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class DeepseekV2RotaryEmbedding(nn.Module):
|
| 115 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
|
| 116 |
+
super().__init__()
|
| 117 |
+
|
| 118 |
+
self.dim = dim
|
| 119 |
+
self.max_position_embeddings = max_position_embeddings
|
| 120 |
+
self.base = base
|
| 121 |
+
inv_freq = 1.0 / (
|
| 122 |
+
self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim)
|
| 123 |
+
)
|
| 124 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 125 |
+
|
| 126 |
+
# Build here to make `torch.jit.trace` work.
|
| 127 |
+
self._set_cos_sin_cache(
|
| 128 |
+
seq_len=max_position_embeddings,
|
| 129 |
+
device=self.inv_freq.device,
|
| 130 |
+
dtype=torch.get_default_dtype(),
|
| 131 |
+
)
|
| 132 |
+
self.max_seq_len_cached = None
|
| 133 |
+
|
| 134 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
| 135 |
+
self.max_seq_len_cached = seq_len
|
| 136 |
+
t = torch.arange(
|
| 137 |
+
self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
freqs = torch.outer(t, self.inv_freq.to(t.device))
|
| 141 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
| 142 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 143 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
| 144 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
| 145 |
+
|
| 146 |
+
def forward(self, x, seq_len=None):
|
| 147 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
| 148 |
+
if self.max_seq_len_cached is None or seq_len > self.max_seq_len_cached:
|
| 149 |
+
self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
|
| 150 |
+
|
| 151 |
+
return (
|
| 152 |
+
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
| 153 |
+
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaLinearScalingRotaryEmbedding with Llama->DeepseekV2
|
| 158 |
+
class DeepseekV2LinearScalingRotaryEmbedding(DeepseekV2RotaryEmbedding):
|
| 159 |
+
"""DeepseekV2RotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
|
| 160 |
+
|
| 161 |
+
def __init__(
|
| 162 |
+
self,
|
| 163 |
+
dim,
|
| 164 |
+
max_position_embeddings=2048,
|
| 165 |
+
base=10000,
|
| 166 |
+
device=None,
|
| 167 |
+
scaling_factor=1.0,
|
| 168 |
+
):
|
| 169 |
+
self.scaling_factor = scaling_factor
|
| 170 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
| 171 |
+
|
| 172 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
| 173 |
+
self.max_seq_len_cached = seq_len
|
| 174 |
+
t = torch.arange(
|
| 175 |
+
self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype
|
| 176 |
+
)
|
| 177 |
+
t = t / self.scaling_factor
|
| 178 |
+
|
| 179 |
+
freqs = torch.outer(t, self.inv_freq)
|
| 180 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
| 181 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 182 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
| 183 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaDynamicNTKScalingRotaryEmbedding with Llama->DeepseekV2
|
| 187 |
+
class DeepseekV2DynamicNTKScalingRotaryEmbedding(DeepseekV2RotaryEmbedding):
|
| 188 |
+
"""DeepseekV2RotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
|
| 189 |
+
|
| 190 |
+
def __init__(
|
| 191 |
+
self,
|
| 192 |
+
dim,
|
| 193 |
+
max_position_embeddings=2048,
|
| 194 |
+
base=10000,
|
| 195 |
+
device=None,
|
| 196 |
+
scaling_factor=1.0,
|
| 197 |
+
):
|
| 198 |
+
self.scaling_factor = scaling_factor
|
| 199 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
| 200 |
+
|
| 201 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
| 202 |
+
self.max_seq_len_cached = seq_len
|
| 203 |
+
|
| 204 |
+
if seq_len > self.max_position_embeddings:
|
| 205 |
+
base = self.base * (
|
| 206 |
+
(self.scaling_factor * seq_len / self.max_position_embeddings)
|
| 207 |
+
- (self.scaling_factor - 1)
|
| 208 |
+
) ** (self.dim / (self.dim - 2))
|
| 209 |
+
inv_freq = 1.0 / (
|
| 210 |
+
base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim)
|
| 211 |
+
)
|
| 212 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 213 |
+
|
| 214 |
+
t = torch.arange(
|
| 215 |
+
self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
freqs = torch.outer(t, self.inv_freq)
|
| 219 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
| 220 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 221 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
| 222 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
# Inverse dim formula to find dim based on number of rotations
|
| 226 |
+
def yarn_find_correction_dim(
|
| 227 |
+
num_rotations, dim, base=10000, max_position_embeddings=2048
|
| 228 |
+
):
|
| 229 |
+
return (dim * math.log(max_position_embeddings / (num_rotations * 2 * math.pi))) / (
|
| 230 |
+
2 * math.log(base)
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
# Find dim range bounds based on rotations
|
| 235 |
+
def yarn_find_correction_range(
|
| 236 |
+
low_rot, high_rot, dim, base=10000, max_position_embeddings=2048
|
| 237 |
+
):
|
| 238 |
+
low = math.floor(
|
| 239 |
+
yarn_find_correction_dim(low_rot, dim, base, max_position_embeddings)
|
| 240 |
+
)
|
| 241 |
+
high = math.ceil(
|
| 242 |
+
yarn_find_correction_dim(high_rot, dim, base, max_position_embeddings)
|
| 243 |
+
)
|
| 244 |
+
return max(low, 0), min(high, dim - 1) # Clamp values just in case
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def yarn_get_mscale(scale=1, mscale=1):
|
| 248 |
+
if scale <= 1:
|
| 249 |
+
return 1.0
|
| 250 |
+
return 0.1 * mscale * math.log(scale) + 1.0
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def yarn_linear_ramp_mask(min, max, dim):
|
| 254 |
+
if min == max:
|
| 255 |
+
max += 0.001 # Prevent singularity
|
| 256 |
+
|
| 257 |
+
linear_func = (torch.arange(dim, dtype=torch.float32) - min) / (max - min)
|
| 258 |
+
ramp_func = torch.clamp(linear_func, 0, 1)
|
| 259 |
+
return ramp_func
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
class DeepseekV2YarnRotaryEmbedding(DeepseekV2RotaryEmbedding):
|
| 263 |
+
|
| 264 |
+
def __init__(
|
| 265 |
+
self,
|
| 266 |
+
dim,
|
| 267 |
+
max_position_embeddings=2048,
|
| 268 |
+
base=10000,
|
| 269 |
+
device=None,
|
| 270 |
+
scaling_factor=1.0,
|
| 271 |
+
original_max_position_embeddings=4096,
|
| 272 |
+
beta_fast=32,
|
| 273 |
+
beta_slow=1,
|
| 274 |
+
mscale=1,
|
| 275 |
+
mscale_all_dim=0,
|
| 276 |
+
):
|
| 277 |
+
self.scaling_factor = scaling_factor
|
| 278 |
+
self.original_max_position_embeddings = original_max_position_embeddings
|
| 279 |
+
self.beta_fast = beta_fast
|
| 280 |
+
self.beta_slow = beta_slow
|
| 281 |
+
self.mscale = mscale
|
| 282 |
+
self.mscale_all_dim = mscale_all_dim
|
| 283 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
| 284 |
+
|
| 285 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
| 286 |
+
self.max_seq_len_cached = seq_len
|
| 287 |
+
dim = self.dim
|
| 288 |
+
|
| 289 |
+
freq_extra = 1.0 / (
|
| 290 |
+
self.base
|
| 291 |
+
** (torch.arange(0, dim, 2, dtype=torch.float32, device=device) / dim)
|
| 292 |
+
)
|
| 293 |
+
freq_inter = 1.0 / (
|
| 294 |
+
self.scaling_factor
|
| 295 |
+
* self.base
|
| 296 |
+
** (torch.arange(0, dim, 2, dtype=torch.float32, device=device) / dim)
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
low, high = yarn_find_correction_range(
|
| 300 |
+
self.beta_fast,
|
| 301 |
+
self.beta_slow,
|
| 302 |
+
dim,
|
| 303 |
+
self.base,
|
| 304 |
+
self.original_max_position_embeddings,
|
| 305 |
+
)
|
| 306 |
+
inv_freq_mask = 1.0 - yarn_linear_ramp_mask(low, high, dim // 2).to(
|
| 307 |
+
device=device, dtype=torch.float32
|
| 308 |
+
)
|
| 309 |
+
inv_freq = freq_inter * (1 - inv_freq_mask) + freq_extra * inv_freq_mask
|
| 310 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 311 |
+
|
| 312 |
+
t = torch.arange(seq_len, device=device, dtype=torch.float32)
|
| 313 |
+
|
| 314 |
+
freqs = torch.outer(t, inv_freq)
|
| 315 |
+
|
| 316 |
+
_mscale = float(
|
| 317 |
+
yarn_get_mscale(self.scaling_factor, self.mscale)
|
| 318 |
+
/ yarn_get_mscale(self.scaling_factor, self.mscale_all_dim)
|
| 319 |
+
)
|
| 320 |
+
|
| 321 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 322 |
+
self.register_buffer(
|
| 323 |
+
"cos_cached", (emb.cos() * _mscale).to(dtype), persistent=False
|
| 324 |
+
)
|
| 325 |
+
self.register_buffer(
|
| 326 |
+
"sin_cached", (emb.sin() * _mscale).to(dtype), persistent=False
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
# Copied from transformers.models.llama.modeling_llama.rotate_half
|
| 331 |
+
def rotate_half(x):
|
| 332 |
+
"""Rotates half the hidden dims of the input."""
|
| 333 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 334 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 335 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
# Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
|
| 339 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids, unsqueeze_dim=1):
|
| 340 |
+
"""Applies Rotary Position Embedding to the query and key tensors.
|
| 341 |
+
|
| 342 |
+
Args:
|
| 343 |
+
q (`torch.Tensor`): The query tensor.
|
| 344 |
+
k (`torch.Tensor`): The key tensor.
|
| 345 |
+
cos (`torch.Tensor`): The cosine part of the rotary embedding.
|
| 346 |
+
sin (`torch.Tensor`): The sine part of the rotary embedding.
|
| 347 |
+
position_ids (`torch.Tensor`):
|
| 348 |
+
The position indices of the tokens corresponding to the query and key tensors. For example, this can be
|
| 349 |
+
used to pass offsetted position ids when working with a KV-cache.
|
| 350 |
+
unsqueeze_dim (`int`, *optional*, defaults to 1):
|
| 351 |
+
The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
|
| 352 |
+
sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
|
| 353 |
+
that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
|
| 354 |
+
k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
|
| 355 |
+
cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
|
| 356 |
+
the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
|
| 357 |
+
Returns:
|
| 358 |
+
`tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
|
| 359 |
+
"""
|
| 360 |
+
cos = cos[position_ids].unsqueeze(unsqueeze_dim)
|
| 361 |
+
sin = sin[position_ids].unsqueeze(unsqueeze_dim)
|
| 362 |
+
|
| 363 |
+
b, h, s, d = q.shape
|
| 364 |
+
q = q.view(b, h, s, d // 2, 2).transpose(4, 3).reshape(b, h, s, d)
|
| 365 |
+
|
| 366 |
+
b, h, s, d = k.shape
|
| 367 |
+
k = k.view(b, h, s, d // 2, 2).transpose(4, 3).reshape(b, h, s, d)
|
| 368 |
+
|
| 369 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 370 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 371 |
+
return q_embed, k_embed
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
class DeepseekV2MLP(nn.Module):
|
| 375 |
+
def __init__(self, config, hidden_size=None, intermediate_size=None):
|
| 376 |
+
super().__init__()
|
| 377 |
+
self.config = config
|
| 378 |
+
self.hidden_size = config.hidden_size if hidden_size is None else hidden_size
|
| 379 |
+
self.intermediate_size = (
|
| 380 |
+
config.intermediate_size if intermediate_size is None else intermediate_size
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 384 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 385 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 386 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 387 |
+
|
| 388 |
+
def forward(self, x):
|
| 389 |
+
down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 390 |
+
return down_proj
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
class MoEGate(nn.Module):
|
| 394 |
+
def __init__(self, config):
|
| 395 |
+
super().__init__()
|
| 396 |
+
self.config = config
|
| 397 |
+
self.top_k = config.num_experts_per_tok
|
| 398 |
+
self.n_routed_experts = config.n_routed_experts
|
| 399 |
+
self.routed_scaling_factor = config.routed_scaling_factor
|
| 400 |
+
self.scoring_func = config.scoring_func
|
| 401 |
+
self.alpha = config.aux_loss_alpha
|
| 402 |
+
self.seq_aux = config.seq_aux
|
| 403 |
+
self.topk_method = config.topk_method
|
| 404 |
+
self.n_group = config.n_group
|
| 405 |
+
self.topk_group = config.topk_group
|
| 406 |
+
|
| 407 |
+
# topk selection algorithm
|
| 408 |
+
self.norm_topk_prob = config.norm_topk_prob
|
| 409 |
+
self.gating_dim = config.hidden_size
|
| 410 |
+
self.weight = nn.Parameter(
|
| 411 |
+
torch.empty((self.n_routed_experts, self.gating_dim))
|
| 412 |
+
)
|
| 413 |
+
self.reset_parameters()
|
| 414 |
+
|
| 415 |
+
def reset_parameters(self) -> None:
|
| 416 |
+
import torch.nn.init as init
|
| 417 |
+
|
| 418 |
+
init.kaiming_uniform_(self.weight, a=math.sqrt(5))
|
| 419 |
+
|
| 420 |
+
def forward(self, hidden_states):
|
| 421 |
+
bsz, seq_len, h = hidden_states.shape
|
| 422 |
+
### compute gating score
|
| 423 |
+
hidden_states = hidden_states.view(-1, h)
|
| 424 |
+
logits = F.linear(
|
| 425 |
+
hidden_states.type(torch.float32), self.weight.type(torch.float32), None
|
| 426 |
+
)
|
| 427 |
+
if self.scoring_func == "softmax":
|
| 428 |
+
scores = logits.softmax(dim=-1, dtype=torch.float32)
|
| 429 |
+
else:
|
| 430 |
+
raise NotImplementedError(
|
| 431 |
+
f"insupportable scoring function for MoE gating: {self.scoring_func}"
|
| 432 |
+
)
|
| 433 |
+
|
| 434 |
+
### select top-k experts
|
| 435 |
+
if self.topk_method == "greedy":
|
| 436 |
+
topk_weight, topk_idx = torch.topk(
|
| 437 |
+
scores, k=self.top_k, dim=-1, sorted=False
|
| 438 |
+
)
|
| 439 |
+
elif self.topk_method == "group_limited_greedy":
|
| 440 |
+
group_scores = (
|
| 441 |
+
scores.view(bsz * seq_len, self.n_group, -1).max(dim=-1).values
|
| 442 |
+
) # [n, n_group]
|
| 443 |
+
group_idx = torch.topk(
|
| 444 |
+
group_scores, k=self.topk_group, dim=-1, sorted=False
|
| 445 |
+
)[
|
| 446 |
+
1
|
| 447 |
+
] # [n, top_k_group]
|
| 448 |
+
group_mask = torch.zeros_like(group_scores) # [n, n_group]
|
| 449 |
+
group_mask.scatter_(1, group_idx, 1) # [n, n_group]
|
| 450 |
+
score_mask = (
|
| 451 |
+
group_mask.unsqueeze(-1)
|
| 452 |
+
.expand(
|
| 453 |
+
bsz * seq_len, self.n_group, self.n_routed_experts // self.n_group
|
| 454 |
+
)
|
| 455 |
+
.reshape(bsz * seq_len, -1)
|
| 456 |
+
) # [n, e]
|
| 457 |
+
tmp_scores = scores.masked_fill(~score_mask.bool(), 0.0) # [n, e]
|
| 458 |
+
topk_weight, topk_idx = torch.topk(
|
| 459 |
+
tmp_scores, k=self.top_k, dim=-1, sorted=False
|
| 460 |
+
)
|
| 461 |
+
|
| 462 |
+
### norm gate to sum 1
|
| 463 |
+
if self.top_k > 1 and self.norm_topk_prob:
|
| 464 |
+
denominator = topk_weight.sum(dim=-1, keepdim=True) + 1e-20
|
| 465 |
+
topk_weight = topk_weight / denominator
|
| 466 |
+
else:
|
| 467 |
+
topk_weight = topk_weight * self.routed_scaling_factor
|
| 468 |
+
### expert-level computation auxiliary loss
|
| 469 |
+
if self.training and self.alpha > 0.0:
|
| 470 |
+
scores_for_aux = scores
|
| 471 |
+
aux_topk = self.top_k
|
| 472 |
+
# always compute aux loss based on the naive greedy topk method
|
| 473 |
+
topk_idx_for_aux_loss = topk_idx.view(bsz, -1)
|
| 474 |
+
if self.seq_aux:
|
| 475 |
+
scores_for_seq_aux = scores_for_aux.view(bsz, seq_len, -1)
|
| 476 |
+
ce = torch.zeros(
|
| 477 |
+
bsz, self.n_routed_experts, device=hidden_states.device
|
| 478 |
+
)
|
| 479 |
+
ce.scatter_add_(
|
| 480 |
+
1,
|
| 481 |
+
topk_idx_for_aux_loss,
|
| 482 |
+
torch.ones(bsz, seq_len * aux_topk, device=hidden_states.device),
|
| 483 |
+
).div_(seq_len * aux_topk / self.n_routed_experts)
|
| 484 |
+
aux_loss = (ce * scores_for_seq_aux.mean(dim=1)).sum(
|
| 485 |
+
dim=1
|
| 486 |
+
).mean() * self.alpha
|
| 487 |
+
else:
|
| 488 |
+
mask_ce = F.one_hot(
|
| 489 |
+
topk_idx_for_aux_loss.view(-1), num_classes=self.n_routed_experts
|
| 490 |
+
)
|
| 491 |
+
ce = mask_ce.float().mean(0)
|
| 492 |
+
Pi = scores_for_aux.mean(0)
|
| 493 |
+
fi = ce * self.n_routed_experts
|
| 494 |
+
aux_loss = (Pi * fi).sum() * self.alpha
|
| 495 |
+
else:
|
| 496 |
+
aux_loss = None
|
| 497 |
+
return topk_idx, topk_weight, aux_loss
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
class AddAuxiliaryLoss(torch.autograd.Function):
|
| 501 |
+
"""
|
| 502 |
+
The trick function of adding auxiliary (aux) loss,
|
| 503 |
+
which includes the gradient of the aux loss during backpropagation.
|
| 504 |
+
"""
|
| 505 |
+
|
| 506 |
+
@staticmethod
|
| 507 |
+
def forward(ctx, x, loss):
|
| 508 |
+
assert loss.numel() == 1
|
| 509 |
+
ctx.dtype = loss.dtype
|
| 510 |
+
ctx.required_aux_loss = loss.requires_grad
|
| 511 |
+
return x
|
| 512 |
+
|
| 513 |
+
@staticmethod
|
| 514 |
+
def backward(ctx, grad_output):
|
| 515 |
+
grad_loss = None
|
| 516 |
+
if ctx.required_aux_loss:
|
| 517 |
+
grad_loss = torch.ones(1, dtype=ctx.dtype, device=grad_output.device)
|
| 518 |
+
return grad_output, grad_loss
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
class DeepseekV2MoE(nn.Module):
|
| 522 |
+
"""
|
| 523 |
+
A mixed expert module containing shared experts.
|
| 524 |
+
"""
|
| 525 |
+
|
| 526 |
+
def __init__(self, config):
|
| 527 |
+
super().__init__()
|
| 528 |
+
self.config = config
|
| 529 |
+
self.num_experts_per_tok = config.num_experts_per_tok
|
| 530 |
+
|
| 531 |
+
if hasattr(config, "ep_size") and config.ep_size > 1:
|
| 532 |
+
assert config.ep_size == dist.get_world_size()
|
| 533 |
+
self.ep_size = config.ep_size
|
| 534 |
+
self.experts_per_rank = config.n_routed_experts // config.ep_size
|
| 535 |
+
self.ep_rank = dist.get_rank()
|
| 536 |
+
self.experts = nn.ModuleList(
|
| 537 |
+
[
|
| 538 |
+
(
|
| 539 |
+
DeepseekV2MLP(
|
| 540 |
+
config, intermediate_size=config.moe_intermediate_size
|
| 541 |
+
)
|
| 542 |
+
if i >= self.ep_rank * self.experts_per_rank
|
| 543 |
+
and i < (self.ep_rank + 1) * self.experts_per_rank
|
| 544 |
+
else None
|
| 545 |
+
)
|
| 546 |
+
for i in range(config.n_routed_experts)
|
| 547 |
+
]
|
| 548 |
+
)
|
| 549 |
+
else:
|
| 550 |
+
self.ep_size = 1
|
| 551 |
+
self.experts_per_rank = config.n_routed_experts
|
| 552 |
+
self.ep_rank = 0
|
| 553 |
+
self.experts = nn.ModuleList(
|
| 554 |
+
[
|
| 555 |
+
DeepseekV2MLP(
|
| 556 |
+
config, intermediate_size=config.moe_intermediate_size
|
| 557 |
+
)
|
| 558 |
+
for i in range(config.n_routed_experts)
|
| 559 |
+
]
|
| 560 |
+
)
|
| 561 |
+
self.gate = MoEGate(config)
|
| 562 |
+
if config.n_shared_experts is not None:
|
| 563 |
+
intermediate_size = config.moe_intermediate_size * config.n_shared_experts
|
| 564 |
+
self.shared_experts = DeepseekV2MLP(
|
| 565 |
+
config=config, intermediate_size=intermediate_size
|
| 566 |
+
)
|
| 567 |
+
|
| 568 |
+
def forward(self, hidden_states):
|
| 569 |
+
identity = hidden_states
|
| 570 |
+
orig_shape = hidden_states.shape
|
| 571 |
+
topk_idx, topk_weight, aux_loss = self.gate(hidden_states)
|
| 572 |
+
hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
|
| 573 |
+
flat_topk_idx = topk_idx.view(-1)
|
| 574 |
+
if self.training:
|
| 575 |
+
hidden_states = hidden_states.repeat_interleave(
|
| 576 |
+
self.num_experts_per_tok, dim=0
|
| 577 |
+
)
|
| 578 |
+
y = torch.empty_like(hidden_states)
|
| 579 |
+
for i, expert in enumerate(self.experts):
|
| 580 |
+
y[flat_topk_idx == i] = expert(hidden_states[flat_topk_idx == i])
|
| 581 |
+
y = (y.view(*topk_weight.shape, -1) * topk_weight.unsqueeze(-1)).sum(dim=1)
|
| 582 |
+
y = y.to(hidden_states.dtype).view(*orig_shape)
|
| 583 |
+
y = AddAuxiliaryLoss.apply(y, aux_loss)
|
| 584 |
+
else:
|
| 585 |
+
y = self.moe_infer(hidden_states, topk_idx, topk_weight).view(*orig_shape)
|
| 586 |
+
if self.config.n_shared_experts is not None:
|
| 587 |
+
y = y + self.shared_experts(identity)
|
| 588 |
+
return y
|
| 589 |
+
|
| 590 |
+
@torch.no_grad()
|
| 591 |
+
def moe_infer(self, x, topk_ids, topk_weight):
|
| 592 |
+
cnts = topk_ids.new_zeros((topk_ids.shape[0], len(self.experts)))
|
| 593 |
+
cnts.scatter_(1, topk_ids, 1)
|
| 594 |
+
tokens_per_expert = cnts.sum(dim=0)
|
| 595 |
+
idxs = topk_ids.view(-1).argsort()
|
| 596 |
+
sorted_tokens = x[idxs // topk_ids.shape[1]]
|
| 597 |
+
sorted_tokens_shape = sorted_tokens.shape
|
| 598 |
+
if self.ep_size > 1:
|
| 599 |
+
tokens_per_ep_rank = tokens_per_expert.view(self.ep_size, -1).sum(dim=1)
|
| 600 |
+
tokens_per_expert_group = tokens_per_expert.new_empty(
|
| 601 |
+
tokens_per_expert.shape[0]
|
| 602 |
+
)
|
| 603 |
+
dist.all_to_all_single(tokens_per_expert_group, tokens_per_expert)
|
| 604 |
+
output_splits = (
|
| 605 |
+
tokens_per_expert_group.view(self.ep_size, -1)
|
| 606 |
+
.sum(1)
|
| 607 |
+
.cpu()
|
| 608 |
+
.numpy()
|
| 609 |
+
.tolist()
|
| 610 |
+
)
|
| 611 |
+
gathered_tokens = sorted_tokens.new_empty(
|
| 612 |
+
tokens_per_expert_group.sum(dim=0).cpu().item(), sorted_tokens.shape[1]
|
| 613 |
+
)
|
| 614 |
+
input_split_sizes = tokens_per_ep_rank.cpu().numpy().tolist()
|
| 615 |
+
dist.all_to_all(
|
| 616 |
+
list(gathered_tokens.split(output_splits)),
|
| 617 |
+
list(sorted_tokens.split(input_split_sizes)),
|
| 618 |
+
)
|
| 619 |
+
tokens_per_expert_post_gather = tokens_per_expert_group.view(
|
| 620 |
+
self.ep_size, self.experts_per_rank
|
| 621 |
+
).sum(dim=0)
|
| 622 |
+
gatherd_idxs = np.zeros(shape=(gathered_tokens.shape[0],), dtype=np.int32)
|
| 623 |
+
s = 0
|
| 624 |
+
for i, k in enumerate(tokens_per_expert_group.cpu().numpy()):
|
| 625 |
+
gatherd_idxs[s : s + k] = i % self.experts_per_rank
|
| 626 |
+
s += k
|
| 627 |
+
gatherd_idxs = gatherd_idxs.argsort()
|
| 628 |
+
sorted_tokens = gathered_tokens[gatherd_idxs]
|
| 629 |
+
tokens_per_expert = tokens_per_expert_post_gather
|
| 630 |
+
tokens_per_expert = tokens_per_expert.cpu().numpy()
|
| 631 |
+
|
| 632 |
+
outputs = []
|
| 633 |
+
start_idx = 0
|
| 634 |
+
for i, num_tokens in enumerate(tokens_per_expert):
|
| 635 |
+
end_idx = start_idx + num_tokens
|
| 636 |
+
if num_tokens == 0:
|
| 637 |
+
continue
|
| 638 |
+
expert = self.experts[i + self.ep_rank * self.experts_per_rank]
|
| 639 |
+
tokens_for_this_expert = sorted_tokens[start_idx:end_idx]
|
| 640 |
+
expert_out = expert(tokens_for_this_expert)
|
| 641 |
+
outputs.append(expert_out)
|
| 642 |
+
start_idx = end_idx
|
| 643 |
+
|
| 644 |
+
outs = torch.cat(outputs, dim=0) if len(outputs) else sorted_tokens.new_empty(0)
|
| 645 |
+
if self.ep_size > 1:
|
| 646 |
+
new_x = torch.empty_like(outs)
|
| 647 |
+
new_x[gatherd_idxs] = outs
|
| 648 |
+
gathered_tokens = new_x.new_empty(*sorted_tokens_shape)
|
| 649 |
+
dist.all_to_all(
|
| 650 |
+
list(gathered_tokens.split(input_split_sizes)),
|
| 651 |
+
list(new_x.split(output_splits)),
|
| 652 |
+
)
|
| 653 |
+
outs = gathered_tokens
|
| 654 |
+
|
| 655 |
+
new_x = torch.empty_like(outs)
|
| 656 |
+
new_x[idxs] = outs
|
| 657 |
+
final_out = (
|
| 658 |
+
new_x.view(*topk_ids.shape, -1)
|
| 659 |
+
.type(topk_weight.dtype)
|
| 660 |
+
.mul_(topk_weight.unsqueeze(dim=-1))
|
| 661 |
+
.sum(dim=1)
|
| 662 |
+
.type(new_x.dtype)
|
| 663 |
+
)
|
| 664 |
+
return final_out
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
# Copied from transformers.models.llama.modeling_llama.repeat_kv
|
| 668 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 669 |
+
"""
|
| 670 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
| 671 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
| 672 |
+
"""
|
| 673 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 674 |
+
if n_rep == 1:
|
| 675 |
+
return hidden_states
|
| 676 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(
|
| 677 |
+
batch, num_key_value_heads, n_rep, slen, head_dim
|
| 678 |
+
)
|
| 679 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 680 |
+
|
| 681 |
+
|
| 682 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaAttention with Llama->DeepseekV2
|
| 683 |
+
class DeepseekV2Attention(nn.Module):
|
| 684 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
| 685 |
+
|
| 686 |
+
def __init__(self, config: DeepseekV2Config, layer_idx: Optional[int] = None):
|
| 687 |
+
super().__init__()
|
| 688 |
+
self.config = config
|
| 689 |
+
self.layer_idx = layer_idx
|
| 690 |
+
if layer_idx is None:
|
| 691 |
+
logger.warning_once(
|
| 692 |
+
f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
|
| 693 |
+
"to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
|
| 694 |
+
"when creating this class."
|
| 695 |
+
)
|
| 696 |
+
|
| 697 |
+
self.attention_dropout = config.attention_dropout
|
| 698 |
+
self.hidden_size = config.hidden_size
|
| 699 |
+
self.num_heads = config.num_attention_heads
|
| 700 |
+
|
| 701 |
+
self.max_position_embeddings = config.max_position_embeddings
|
| 702 |
+
self.rope_theta = config.rope_theta
|
| 703 |
+
self.q_lora_rank = config.q_lora_rank
|
| 704 |
+
self.qk_rope_head_dim = config.qk_rope_head_dim
|
| 705 |
+
self.kv_lora_rank = config.kv_lora_rank
|
| 706 |
+
self.v_head_dim = config.v_head_dim
|
| 707 |
+
self.qk_nope_head_dim = config.qk_nope_head_dim
|
| 708 |
+
self.q_head_dim = config.qk_nope_head_dim + config.qk_rope_head_dim
|
| 709 |
+
|
| 710 |
+
self.is_causal = True
|
| 711 |
+
|
| 712 |
+
if self.q_lora_rank is None:
|
| 713 |
+
self.q_proj = nn.Linear(
|
| 714 |
+
self.hidden_size, self.num_heads * self.q_head_dim, bias=False
|
| 715 |
+
)
|
| 716 |
+
else:
|
| 717 |
+
self.q_a_proj = nn.Linear(
|
| 718 |
+
self.hidden_size, config.q_lora_rank, bias=config.attention_bias
|
| 719 |
+
)
|
| 720 |
+
self.q_a_layernorm = DeepseekV2RMSNorm(config.q_lora_rank)
|
| 721 |
+
self.q_b_proj = nn.Linear(
|
| 722 |
+
config.q_lora_rank, self.num_heads * self.q_head_dim, bias=False
|
| 723 |
+
)
|
| 724 |
+
|
| 725 |
+
self.kv_a_proj_with_mqa = nn.Linear(
|
| 726 |
+
self.hidden_size,
|
| 727 |
+
config.kv_lora_rank + config.qk_rope_head_dim,
|
| 728 |
+
bias=config.attention_bias,
|
| 729 |
+
)
|
| 730 |
+
self.kv_a_layernorm = DeepseekV2RMSNorm(config.kv_lora_rank)
|
| 731 |
+
self.kv_b_proj = nn.Linear(
|
| 732 |
+
config.kv_lora_rank,
|
| 733 |
+
self.num_heads
|
| 734 |
+
* (self.q_head_dim - self.qk_rope_head_dim + self.v_head_dim),
|
| 735 |
+
bias=False,
|
| 736 |
+
)
|
| 737 |
+
|
| 738 |
+
self.o_proj = nn.Linear(
|
| 739 |
+
self.num_heads * self.v_head_dim,
|
| 740 |
+
self.hidden_size,
|
| 741 |
+
bias=config.attention_bias,
|
| 742 |
+
)
|
| 743 |
+
self._init_rope()
|
| 744 |
+
|
| 745 |
+
self.softmax_scale = self.q_head_dim ** (-0.5)
|
| 746 |
+
if self.config.rope_scaling is not None:
|
| 747 |
+
mscale_all_dim = self.config.rope_scaling.get("mscale_all_dim", 0)
|
| 748 |
+
scaling_factor = self.config.rope_scaling["factor"]
|
| 749 |
+
if mscale_all_dim:
|
| 750 |
+
mscale = yarn_get_mscale(scaling_factor, mscale_all_dim)
|
| 751 |
+
self.softmax_scale = self.softmax_scale * mscale * mscale
|
| 752 |
+
|
| 753 |
+
def _init_rope(self):
|
| 754 |
+
if self.config.rope_scaling is None:
|
| 755 |
+
self.rotary_emb = DeepseekV2RotaryEmbedding(
|
| 756 |
+
self.qk_rope_head_dim,
|
| 757 |
+
max_position_embeddings=self.max_position_embeddings,
|
| 758 |
+
base=self.rope_theta,
|
| 759 |
+
)
|
| 760 |
+
else:
|
| 761 |
+
scaling_type = self.config.rope_scaling["type"]
|
| 762 |
+
scaling_factor = self.config.rope_scaling["factor"]
|
| 763 |
+
if scaling_type == "linear":
|
| 764 |
+
self.rotary_emb = DeepseekV2LinearScalingRotaryEmbedding(
|
| 765 |
+
self.qk_rope_head_dim,
|
| 766 |
+
max_position_embeddings=self.max_position_embeddings,
|
| 767 |
+
scaling_factor=scaling_factor,
|
| 768 |
+
base=self.rope_theta,
|
| 769 |
+
)
|
| 770 |
+
elif scaling_type == "dynamic":
|
| 771 |
+
self.rotary_emb = DeepseekV2DynamicNTKScalingRotaryEmbedding(
|
| 772 |
+
self.qk_rope_head_dim,
|
| 773 |
+
max_position_embeddings=self.max_position_embeddings,
|
| 774 |
+
scaling_factor=scaling_factor,
|
| 775 |
+
base=self.rope_theta,
|
| 776 |
+
)
|
| 777 |
+
elif scaling_type == "yarn":
|
| 778 |
+
kwargs = {
|
| 779 |
+
key: self.config.rope_scaling[key]
|
| 780 |
+
for key in [
|
| 781 |
+
"original_max_position_embeddings",
|
| 782 |
+
"beta_fast",
|
| 783 |
+
"beta_slow",
|
| 784 |
+
"mscale",
|
| 785 |
+
"mscale_all_dim",
|
| 786 |
+
]
|
| 787 |
+
if key in self.config.rope_scaling
|
| 788 |
+
}
|
| 789 |
+
self.rotary_emb = DeepseekV2YarnRotaryEmbedding(
|
| 790 |
+
self.qk_rope_head_dim,
|
| 791 |
+
max_position_embeddings=self.max_position_embeddings,
|
| 792 |
+
scaling_factor=scaling_factor,
|
| 793 |
+
base=self.rope_theta,
|
| 794 |
+
**kwargs,
|
| 795 |
+
)
|
| 796 |
+
else:
|
| 797 |
+
raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
|
| 798 |
+
|
| 799 |
+
def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
|
| 800 |
+
return (
|
| 801 |
+
tensor.view(bsz, seq_len, self.num_heads, self.v_head_dim)
|
| 802 |
+
.transpose(1, 2)
|
| 803 |
+
.contiguous()
|
| 804 |
+
)
|
| 805 |
+
|
| 806 |
+
def forward(
|
| 807 |
+
self,
|
| 808 |
+
hidden_states: torch.Tensor,
|
| 809 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 810 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 811 |
+
past_key_value: Optional[Cache] = None,
|
| 812 |
+
output_attentions: bool = False,
|
| 813 |
+
use_cache: bool = False,
|
| 814 |
+
**kwargs,
|
| 815 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 816 |
+
if "padding_mask" in kwargs:
|
| 817 |
+
warnings.warn(
|
| 818 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 819 |
+
)
|
| 820 |
+
bsz, q_len, _ = hidden_states.size()
|
| 821 |
+
|
| 822 |
+
if self.q_lora_rank is None:
|
| 823 |
+
q = self.q_proj(hidden_states)
|
| 824 |
+
else:
|
| 825 |
+
q = self.q_b_proj(self.q_a_layernorm(self.q_a_proj(hidden_states)))
|
| 826 |
+
q = q.view(bsz, q_len, self.num_heads, self.q_head_dim).transpose(1, 2)
|
| 827 |
+
q_nope, q_pe = torch.split(
|
| 828 |
+
q, [self.qk_nope_head_dim, self.qk_rope_head_dim], dim=-1
|
| 829 |
+
)
|
| 830 |
+
|
| 831 |
+
compressed_kv = self.kv_a_proj_with_mqa(hidden_states)
|
| 832 |
+
compressed_kv, k_pe = torch.split(
|
| 833 |
+
compressed_kv, [self.kv_lora_rank, self.qk_rope_head_dim], dim=-1
|
| 834 |
+
)
|
| 835 |
+
k_pe = k_pe.view(bsz, q_len, 1, self.qk_rope_head_dim).transpose(1, 2)
|
| 836 |
+
kv = (
|
| 837 |
+
self.kv_b_proj(self.kv_a_layernorm(compressed_kv))
|
| 838 |
+
.view(bsz, q_len, self.num_heads, self.qk_nope_head_dim + self.v_head_dim)
|
| 839 |
+
.transpose(1, 2)
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
k_nope, value_states = torch.split(
|
| 843 |
+
kv, [self.qk_nope_head_dim, self.v_head_dim], dim=-1
|
| 844 |
+
)
|
| 845 |
+
kv_seq_len = value_states.shape[-2]
|
| 846 |
+
if past_key_value is not None:
|
| 847 |
+
if self.layer_idx is None:
|
| 848 |
+
raise ValueError(
|
| 849 |
+
f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
|
| 850 |
+
"for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
|
| 851 |
+
"with a layer index."
|
| 852 |
+
)
|
| 853 |
+
kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
|
| 854 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
| 855 |
+
|
| 856 |
+
q_pe, k_pe = apply_rotary_pos_emb(q_pe, k_pe, cos, sin, position_ids)
|
| 857 |
+
|
| 858 |
+
query_states = k_pe.new_empty(bsz, self.num_heads, q_len, self.q_head_dim)
|
| 859 |
+
query_states[:, :, :, : self.qk_nope_head_dim] = q_nope
|
| 860 |
+
query_states[:, :, :, self.qk_nope_head_dim :] = q_pe
|
| 861 |
+
|
| 862 |
+
key_states = k_pe.new_empty(bsz, self.num_heads, q_len, self.q_head_dim)
|
| 863 |
+
key_states[:, :, :, : self.qk_nope_head_dim] = k_nope
|
| 864 |
+
key_states[:, :, :, self.qk_nope_head_dim :] = k_pe
|
| 865 |
+
if past_key_value is not None:
|
| 866 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 867 |
+
key_states, value_states = past_key_value.update(
|
| 868 |
+
key_states, value_states, self.layer_idx, cache_kwargs
|
| 869 |
+
)
|
| 870 |
+
|
| 871 |
+
attn_weights = (
|
| 872 |
+
torch.matmul(query_states, key_states.transpose(2, 3)) * self.softmax_scale
|
| 873 |
+
)
|
| 874 |
+
|
| 875 |
+
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
|
| 876 |
+
raise ValueError(
|
| 877 |
+
f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
|
| 878 |
+
f" {attn_weights.size()}"
|
| 879 |
+
)
|
| 880 |
+
assert attention_mask is not None
|
| 881 |
+
if attention_mask is not None:
|
| 882 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
| 883 |
+
raise ValueError(
|
| 884 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
| 885 |
+
)
|
| 886 |
+
attn_weights = attn_weights + attention_mask
|
| 887 |
+
|
| 888 |
+
# upcast attention to fp32
|
| 889 |
+
attn_weights = nn.functional.softmax(
|
| 890 |
+
attn_weights, dim=-1, dtype=torch.float32
|
| 891 |
+
).to(query_states.dtype)
|
| 892 |
+
attn_weights = nn.functional.dropout(
|
| 893 |
+
attn_weights, p=self.attention_dropout, training=self.training
|
| 894 |
+
)
|
| 895 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 896 |
+
|
| 897 |
+
if attn_output.size() != (bsz, self.num_heads, q_len, self.v_head_dim):
|
| 898 |
+
raise ValueError(
|
| 899 |
+
f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.v_head_dim)}, but is"
|
| 900 |
+
f" {attn_output.size()}"
|
| 901 |
+
)
|
| 902 |
+
|
| 903 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 904 |
+
|
| 905 |
+
attn_output = attn_output.reshape(bsz, q_len, self.num_heads * self.v_head_dim)
|
| 906 |
+
|
| 907 |
+
attn_output = self.o_proj(attn_output)
|
| 908 |
+
|
| 909 |
+
if not output_attentions:
|
| 910 |
+
attn_weights = None
|
| 911 |
+
|
| 912 |
+
return attn_output, attn_weights, past_key_value
|
| 913 |
+
|
| 914 |
+
|
| 915 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2 with Llama->DeepseekV2
|
| 916 |
+
class DeepseekV2FlashAttention2(DeepseekV2Attention):
|
| 917 |
+
"""
|
| 918 |
+
DeepseekV2 flash attention module. This module inherits from `DeepseekV2Attention` as the weights of the module stays
|
| 919 |
+
untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
|
| 920 |
+
flash attention and deal with padding tokens in case the input contains any of them.
|
| 921 |
+
"""
|
| 922 |
+
|
| 923 |
+
def __init__(self, *args, **kwargs):
|
| 924 |
+
super().__init__(*args, **kwargs)
|
| 925 |
+
|
| 926 |
+
# TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
|
| 927 |
+
# flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
|
| 928 |
+
# Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
|
| 929 |
+
self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
|
| 930 |
+
|
| 931 |
+
def forward(
|
| 932 |
+
self,
|
| 933 |
+
hidden_states: torch.Tensor,
|
| 934 |
+
attention_mask: Optional[torch.LongTensor] = None,
|
| 935 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 936 |
+
past_key_value: Optional[Cache] = None,
|
| 937 |
+
output_attentions: bool = False,
|
| 938 |
+
use_cache: bool = False,
|
| 939 |
+
**kwargs,
|
| 940 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 941 |
+
# DeepseekV2FlashAttention2 attention does not support output_attentions
|
| 942 |
+
if "padding_mask" in kwargs:
|
| 943 |
+
warnings.warn(
|
| 944 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 945 |
+
)
|
| 946 |
+
|
| 947 |
+
# overwrite attention_mask with padding_mask
|
| 948 |
+
attention_mask = kwargs.pop("padding_mask")
|
| 949 |
+
|
| 950 |
+
output_attentions = False
|
| 951 |
+
|
| 952 |
+
bsz, q_len, _ = hidden_states.size()
|
| 953 |
+
|
| 954 |
+
if self.q_lora_rank is None:
|
| 955 |
+
q = self.q_proj(hidden_states)
|
| 956 |
+
else:
|
| 957 |
+
q = self.q_b_proj(self.q_a_layernorm(self.q_a_proj(hidden_states)))
|
| 958 |
+
q = q.view(bsz, q_len, self.num_heads, self.q_head_dim).transpose(1, 2)
|
| 959 |
+
q_nope, q_pe = torch.split(
|
| 960 |
+
q, [self.qk_nope_head_dim, self.qk_rope_head_dim], dim=-1
|
| 961 |
+
)
|
| 962 |
+
|
| 963 |
+
# Flash attention requires the input to have the shape
|
| 964 |
+
# batch_size x seq_length x head_dim x hidden_dim
|
| 965 |
+
# therefore we just need to keep the original shape
|
| 966 |
+
compressed_kv = self.kv_a_proj_with_mqa(hidden_states)
|
| 967 |
+
compressed_kv, k_pe = torch.split(
|
| 968 |
+
compressed_kv, [self.kv_lora_rank, self.qk_rope_head_dim], dim=-1
|
| 969 |
+
)
|
| 970 |
+
k_pe = k_pe.view(bsz, q_len, 1, self.qk_rope_head_dim).transpose(1, 2)
|
| 971 |
+
kv = (
|
| 972 |
+
self.kv_b_proj(self.kv_a_layernorm(compressed_kv))
|
| 973 |
+
.view(bsz, q_len, self.num_heads, self.qk_nope_head_dim + self.v_head_dim)
|
| 974 |
+
.transpose(1, 2)
|
| 975 |
+
)
|
| 976 |
+
|
| 977 |
+
k_nope, value_states = torch.split(
|
| 978 |
+
kv, [self.qk_nope_head_dim, self.v_head_dim], dim=-1
|
| 979 |
+
)
|
| 980 |
+
kv_seq_len = value_states.shape[-2]
|
| 981 |
+
|
| 982 |
+
kv_seq_len = value_states.shape[-2]
|
| 983 |
+
if past_key_value is not None:
|
| 984 |
+
kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
|
| 985 |
+
|
| 986 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
| 987 |
+
q_pe, k_pe = apply_rotary_pos_emb(q_pe, k_pe, cos, sin, position_ids)
|
| 988 |
+
|
| 989 |
+
query_states = k_pe.new_empty(bsz, self.num_heads, q_len, self.q_head_dim)
|
| 990 |
+
query_states[:, :, :, : self.qk_nope_head_dim] = q_nope
|
| 991 |
+
query_states[:, :, :, self.qk_nope_head_dim :] = q_pe
|
| 992 |
+
|
| 993 |
+
key_states = k_pe.new_empty(bsz, self.num_heads, q_len, self.q_head_dim)
|
| 994 |
+
key_states[:, :, :, : self.qk_nope_head_dim] = k_nope
|
| 995 |
+
key_states[:, :, :, self.qk_nope_head_dim :] = k_pe
|
| 996 |
+
|
| 997 |
+
if self.q_head_dim != self.v_head_dim:
|
| 998 |
+
value_states = F.pad(value_states, [0, self.q_head_dim - self.v_head_dim])
|
| 999 |
+
|
| 1000 |
+
if past_key_value is not None:
|
| 1001 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 1002 |
+
key_states, value_states = past_key_value.update(
|
| 1003 |
+
key_states, value_states, self.layer_idx, cache_kwargs
|
| 1004 |
+
)
|
| 1005 |
+
|
| 1006 |
+
# TODO: These transpose are quite inefficient but Flash Attention requires the layout [batch_size, sequence_length, num_heads, head_dim]. We would need to refactor the KV cache
|
| 1007 |
+
# to be able to avoid many of these transpose/reshape/view.
|
| 1008 |
+
query_states = query_states.transpose(1, 2)
|
| 1009 |
+
key_states = key_states.transpose(1, 2)
|
| 1010 |
+
value_states = value_states.transpose(1, 2)
|
| 1011 |
+
|
| 1012 |
+
dropout_rate = self.attention_dropout if self.training else 0.0
|
| 1013 |
+
|
| 1014 |
+
# In PEFT, usually we cast the layer norms in float32 for training stability reasons
|
| 1015 |
+
# therefore the input hidden states gets silently casted in float32. Hence, we need
|
| 1016 |
+
# cast them back in the correct dtype just to be sure everything works as expected.
|
| 1017 |
+
# This might slowdown training & inference so it is recommended to not cast the LayerNorms
|
| 1018 |
+
# in fp32. (DeepseekV2RMSNorm handles it correctly)
|
| 1019 |
+
|
| 1020 |
+
input_dtype = query_states.dtype
|
| 1021 |
+
if input_dtype == torch.float32:
|
| 1022 |
+
# Handle the case where the model is quantized
|
| 1023 |
+
if hasattr(self.config, "_pre_quantization_dtype"):
|
| 1024 |
+
target_dtype = self.config._pre_quantization_dtype
|
| 1025 |
+
elif torch.is_autocast_enabled():
|
| 1026 |
+
target_dtype = torch.get_autocast_gpu_dtype()
|
| 1027 |
+
else:
|
| 1028 |
+
target_dtype = (
|
| 1029 |
+
self.q_proj.weight.dtype
|
| 1030 |
+
if self.q_lora_rank is None
|
| 1031 |
+
else self.q_a_proj.weight.dtype
|
| 1032 |
+
)
|
| 1033 |
+
|
| 1034 |
+
logger.warning_once(
|
| 1035 |
+
f"The input hidden states seems to be silently casted in float32, this might be related to"
|
| 1036 |
+
f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
|
| 1037 |
+
f" {target_dtype}."
|
| 1038 |
+
)
|
| 1039 |
+
|
| 1040 |
+
query_states = query_states.to(target_dtype)
|
| 1041 |
+
key_states = key_states.to(target_dtype)
|
| 1042 |
+
value_states = value_states.to(target_dtype)
|
| 1043 |
+
|
| 1044 |
+
attn_output = self._flash_attention_forward(
|
| 1045 |
+
query_states,
|
| 1046 |
+
key_states,
|
| 1047 |
+
value_states,
|
| 1048 |
+
attention_mask,
|
| 1049 |
+
q_len,
|
| 1050 |
+
dropout=dropout_rate,
|
| 1051 |
+
softmax_scale=self.softmax_scale,
|
| 1052 |
+
)
|
| 1053 |
+
if self.q_head_dim != self.v_head_dim:
|
| 1054 |
+
attn_output = attn_output[:, :, :, : self.v_head_dim]
|
| 1055 |
+
|
| 1056 |
+
attn_output = attn_output.reshape(
|
| 1057 |
+
bsz, q_len, self.num_heads * self.v_head_dim
|
| 1058 |
+
).contiguous()
|
| 1059 |
+
attn_output = self.o_proj(attn_output)
|
| 1060 |
+
|
| 1061 |
+
if not output_attentions:
|
| 1062 |
+
attn_weights = None
|
| 1063 |
+
|
| 1064 |
+
return attn_output, attn_weights, past_key_value
|
| 1065 |
+
|
| 1066 |
+
def _flash_attention_forward(
|
| 1067 |
+
self,
|
| 1068 |
+
query_states,
|
| 1069 |
+
key_states,
|
| 1070 |
+
value_states,
|
| 1071 |
+
attention_mask,
|
| 1072 |
+
query_length,
|
| 1073 |
+
dropout=0.0,
|
| 1074 |
+
softmax_scale=None,
|
| 1075 |
+
):
|
| 1076 |
+
"""
|
| 1077 |
+
Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
|
| 1078 |
+
first unpad the input, then computes the attention scores and pad the final attention scores.
|
| 1079 |
+
|
| 1080 |
+
Args:
|
| 1081 |
+
query_states (`torch.Tensor`):
|
| 1082 |
+
Input query states to be passed to Flash Attention API
|
| 1083 |
+
key_states (`torch.Tensor`):
|
| 1084 |
+
Input key states to be passed to Flash Attention API
|
| 1085 |
+
value_states (`torch.Tensor`):
|
| 1086 |
+
Input value states to be passed to Flash Attention API
|
| 1087 |
+
attention_mask (`torch.Tensor`):
|
| 1088 |
+
The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
|
| 1089 |
+
position of padding tokens and 1 for the position of non-padding tokens.
|
| 1090 |
+
dropout (`int`, *optional*):
|
| 1091 |
+
Attention dropout
|
| 1092 |
+
softmax_scale (`float`, *optional*):
|
| 1093 |
+
The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
|
| 1094 |
+
"""
|
| 1095 |
+
if not self._flash_attn_uses_top_left_mask:
|
| 1096 |
+
causal = self.is_causal
|
| 1097 |
+
else:
|
| 1098 |
+
# TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in DeepseekV2FlashAttention2 __init__.
|
| 1099 |
+
causal = self.is_causal and query_length != 1
|
| 1100 |
+
|
| 1101 |
+
# Contains at least one padding token in the sequence
|
| 1102 |
+
if attention_mask is not None:
|
| 1103 |
+
batch_size = query_states.shape[0]
|
| 1104 |
+
(
|
| 1105 |
+
query_states,
|
| 1106 |
+
key_states,
|
| 1107 |
+
value_states,
|
| 1108 |
+
indices_q,
|
| 1109 |
+
cu_seq_lens,
|
| 1110 |
+
max_seq_lens,
|
| 1111 |
+
) = self._upad_input(
|
| 1112 |
+
query_states, key_states, value_states, attention_mask, query_length
|
| 1113 |
+
)
|
| 1114 |
+
|
| 1115 |
+
cu_seqlens_q, cu_seqlens_k = cu_seq_lens
|
| 1116 |
+
max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
|
| 1117 |
+
|
| 1118 |
+
attn_output_unpad = flash_attn_varlen_func(
|
| 1119 |
+
query_states,
|
| 1120 |
+
key_states,
|
| 1121 |
+
value_states,
|
| 1122 |
+
cu_seqlens_q=cu_seqlens_q,
|
| 1123 |
+
cu_seqlens_k=cu_seqlens_k,
|
| 1124 |
+
max_seqlen_q=max_seqlen_in_batch_q,
|
| 1125 |
+
max_seqlen_k=max_seqlen_in_batch_k,
|
| 1126 |
+
dropout_p=dropout,
|
| 1127 |
+
softmax_scale=softmax_scale,
|
| 1128 |
+
causal=causal,
|
| 1129 |
+
)
|
| 1130 |
+
|
| 1131 |
+
attn_output = pad_input(
|
| 1132 |
+
attn_output_unpad, indices_q, batch_size, query_length
|
| 1133 |
+
)
|
| 1134 |
+
else:
|
| 1135 |
+
attn_output = flash_attn_func(
|
| 1136 |
+
query_states,
|
| 1137 |
+
key_states,
|
| 1138 |
+
value_states,
|
| 1139 |
+
dropout,
|
| 1140 |
+
softmax_scale=softmax_scale,
|
| 1141 |
+
causal=causal,
|
| 1142 |
+
)
|
| 1143 |
+
|
| 1144 |
+
return attn_output
|
| 1145 |
+
|
| 1146 |
+
def _upad_input(
|
| 1147 |
+
self, query_layer, key_layer, value_layer, attention_mask, query_length
|
| 1148 |
+
):
|
| 1149 |
+
indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
|
| 1150 |
+
batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
|
| 1151 |
+
|
| 1152 |
+
key_layer = index_first_axis(
|
| 1153 |
+
key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim),
|
| 1154 |
+
indices_k,
|
| 1155 |
+
)
|
| 1156 |
+
value_layer = index_first_axis(
|
| 1157 |
+
value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim),
|
| 1158 |
+
indices_k,
|
| 1159 |
+
)
|
| 1160 |
+
if query_length == kv_seq_len:
|
| 1161 |
+
query_layer = index_first_axis(
|
| 1162 |
+
query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim),
|
| 1163 |
+
indices_k,
|
| 1164 |
+
)
|
| 1165 |
+
cu_seqlens_q = cu_seqlens_k
|
| 1166 |
+
max_seqlen_in_batch_q = max_seqlen_in_batch_k
|
| 1167 |
+
indices_q = indices_k
|
| 1168 |
+
elif query_length == 1:
|
| 1169 |
+
max_seqlen_in_batch_q = 1
|
| 1170 |
+
cu_seqlens_q = torch.arange(
|
| 1171 |
+
batch_size + 1, dtype=torch.int32, device=query_layer.device
|
| 1172 |
+
) # There is a memcpy here, that is very bad.
|
| 1173 |
+
indices_q = cu_seqlens_q[:-1]
|
| 1174 |
+
query_layer = query_layer.squeeze(1)
|
| 1175 |
+
else:
|
| 1176 |
+
# The -q_len: slice assumes left padding.
|
| 1177 |
+
attention_mask = attention_mask[:, -query_length:]
|
| 1178 |
+
query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(
|
| 1179 |
+
query_layer, attention_mask
|
| 1180 |
+
)
|
| 1181 |
+
|
| 1182 |
+
return (
|
| 1183 |
+
query_layer,
|
| 1184 |
+
key_layer,
|
| 1185 |
+
value_layer,
|
| 1186 |
+
indices_q,
|
| 1187 |
+
(cu_seqlens_q, cu_seqlens_k),
|
| 1188 |
+
(max_seqlen_in_batch_q, max_seqlen_in_batch_k),
|
| 1189 |
+
)
|
| 1190 |
+
|
| 1191 |
+
|
| 1192 |
+
ATTENTION_CLASSES = {
|
| 1193 |
+
"eager": DeepseekV2Attention,
|
| 1194 |
+
"flash_attention_2": DeepseekV2FlashAttention2,
|
| 1195 |
+
}
|
| 1196 |
+
|
| 1197 |
+
|
| 1198 |
+
class DeepseekV2DecoderLayer(nn.Module):
|
| 1199 |
+
def __init__(self, config: DeepseekV2Config, layer_idx: int):
|
| 1200 |
+
super().__init__()
|
| 1201 |
+
self.hidden_size = config.hidden_size
|
| 1202 |
+
|
| 1203 |
+
self.self_attn = ATTENTION_CLASSES[config._attn_implementation](
|
| 1204 |
+
config=config, layer_idx=layer_idx
|
| 1205 |
+
)
|
| 1206 |
+
|
| 1207 |
+
self.mlp = (
|
| 1208 |
+
DeepseekV2MoE(config)
|
| 1209 |
+
if (
|
| 1210 |
+
config.n_routed_experts is not None
|
| 1211 |
+
and layer_idx >= config.first_k_dense_replace
|
| 1212 |
+
and layer_idx % config.moe_layer_freq == 0
|
| 1213 |
+
)
|
| 1214 |
+
else DeepseekV2MLP(config)
|
| 1215 |
+
)
|
| 1216 |
+
self.input_layernorm = DeepseekV2RMSNorm(
|
| 1217 |
+
config.hidden_size, eps=config.rms_norm_eps
|
| 1218 |
+
)
|
| 1219 |
+
self.post_attention_layernorm = DeepseekV2RMSNorm(
|
| 1220 |
+
config.hidden_size, eps=config.rms_norm_eps
|
| 1221 |
+
)
|
| 1222 |
+
|
| 1223 |
+
def forward(
|
| 1224 |
+
self,
|
| 1225 |
+
hidden_states: torch.Tensor,
|
| 1226 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1227 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1228 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
| 1229 |
+
output_attentions: Optional[bool] = False,
|
| 1230 |
+
use_cache: Optional[bool] = False,
|
| 1231 |
+
**kwargs,
|
| 1232 |
+
) -> Tuple[
|
| 1233 |
+
torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]
|
| 1234 |
+
]:
|
| 1235 |
+
"""
|
| 1236 |
+
Args:
|
| 1237 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
| 1238 |
+
attention_mask (`torch.FloatTensor`, *optional*):
|
| 1239 |
+
attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
|
| 1240 |
+
query_sequence_length, key_sequence_length)` if default attention is used.
|
| 1241 |
+
output_attentions (`bool`, *optional*):
|
| 1242 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under
|
| 1243 |
+
returned tensors for more detail.
|
| 1244 |
+
use_cache (`bool`, *optional*):
|
| 1245 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
| 1246 |
+
(see `past_key_values`).
|
| 1247 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
|
| 1248 |
+
"""
|
| 1249 |
+
if "padding_mask" in kwargs:
|
| 1250 |
+
warnings.warn(
|
| 1251 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 1252 |
+
)
|
| 1253 |
+
residual = hidden_states
|
| 1254 |
+
|
| 1255 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 1256 |
+
|
| 1257 |
+
# Self Attention
|
| 1258 |
+
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
| 1259 |
+
hidden_states=hidden_states,
|
| 1260 |
+
attention_mask=attention_mask,
|
| 1261 |
+
position_ids=position_ids,
|
| 1262 |
+
past_key_value=past_key_value,
|
| 1263 |
+
output_attentions=output_attentions,
|
| 1264 |
+
use_cache=use_cache,
|
| 1265 |
+
**kwargs,
|
| 1266 |
+
)
|
| 1267 |
+
hidden_states = residual + hidden_states
|
| 1268 |
+
|
| 1269 |
+
# Fully Connected
|
| 1270 |
+
residual = hidden_states
|
| 1271 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 1272 |
+
hidden_states = self.mlp(hidden_states)
|
| 1273 |
+
hidden_states = residual + hidden_states
|
| 1274 |
+
|
| 1275 |
+
outputs = (hidden_states,)
|
| 1276 |
+
|
| 1277 |
+
if output_attentions:
|
| 1278 |
+
outputs += (self_attn_weights,)
|
| 1279 |
+
|
| 1280 |
+
if use_cache:
|
| 1281 |
+
outputs += (present_key_value,)
|
| 1282 |
+
|
| 1283 |
+
return outputs
|
| 1284 |
+
|
| 1285 |
+
|
| 1286 |
+
DeepseekV2_START_DOCSTRING = r"""
|
| 1287 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
| 1288 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
| 1289 |
+
etc.)
|
| 1290 |
+
|
| 1291 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
| 1292 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
| 1293 |
+
and behavior.
|
| 1294 |
+
|
| 1295 |
+
Parameters:
|
| 1296 |
+
config ([`DeepseekV2Config`]):
|
| 1297 |
+
Model configuration class with all the parameters of the model. Initializing with a config file does not
|
| 1298 |
+
load the weights associated with the model, only the configuration. Check out the
|
| 1299 |
+
[`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
| 1300 |
+
"""
|
| 1301 |
+
|
| 1302 |
+
|
| 1303 |
+
@add_start_docstrings(
|
| 1304 |
+
"The bare DeepseekV2 Model outputting raw hidden-states without any specific head on top.",
|
| 1305 |
+
DeepseekV2_START_DOCSTRING,
|
| 1306 |
+
)
|
| 1307 |
+
class DeepseekV2PreTrainedModel(PreTrainedModel):
|
| 1308 |
+
config_class = DeepseekV2Config
|
| 1309 |
+
base_model_prefix = "model"
|
| 1310 |
+
supports_gradient_checkpointing = True
|
| 1311 |
+
_no_split_modules = ["DeepseekV2DecoderLayer"]
|
| 1312 |
+
_skip_keys_device_placement = "past_key_values"
|
| 1313 |
+
_supports_flash_attn_2 = True
|
| 1314 |
+
_supports_cache_class = True
|
| 1315 |
+
|
| 1316 |
+
def _init_weights(self, module):
|
| 1317 |
+
std = self.config.initializer_range
|
| 1318 |
+
if isinstance(module, nn.Linear):
|
| 1319 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 1320 |
+
if module.bias is not None:
|
| 1321 |
+
module.bias.data.zero_()
|
| 1322 |
+
elif isinstance(module, nn.Embedding):
|
| 1323 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 1324 |
+
if module.padding_idx is not None:
|
| 1325 |
+
module.weight.data[module.padding_idx].zero_()
|
| 1326 |
+
|
| 1327 |
+
|
| 1328 |
+
DeepseekV2_INPUTS_DOCSTRING = r"""
|
| 1329 |
+
Args:
|
| 1330 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
| 1331 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
| 1332 |
+
it.
|
| 1333 |
+
|
| 1334 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
| 1335 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
| 1336 |
+
|
| 1337 |
+
[What are input IDs?](../glossary#input-ids)
|
| 1338 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1339 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
| 1340 |
+
|
| 1341 |
+
- 1 for tokens that are **not masked**,
|
| 1342 |
+
- 0 for tokens that are **masked**.
|
| 1343 |
+
|
| 1344 |
+
[What are attention masks?](../glossary#attention-mask)
|
| 1345 |
+
|
| 1346 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
| 1347 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
| 1348 |
+
|
| 1349 |
+
If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
|
| 1350 |
+
`past_key_values`).
|
| 1351 |
+
|
| 1352 |
+
If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
|
| 1353 |
+
and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
|
| 1354 |
+
information on the default strategy.
|
| 1355 |
+
|
| 1356 |
+
- 1 indicates the head is **not masked**,
|
| 1357 |
+
- 0 indicates the head is **masked**.
|
| 1358 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1359 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
| 1360 |
+
config.n_positions - 1]`.
|
| 1361 |
+
|
| 1362 |
+
[What are position IDs?](../glossary#position-ids)
|
| 1363 |
+
past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
|
| 1364 |
+
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
|
| 1365 |
+
blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
|
| 1366 |
+
returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
|
| 1367 |
+
|
| 1368 |
+
Two formats are allowed:
|
| 1369 |
+
- a [`~cache_utils.Cache`] instance;
|
| 1370 |
+
- Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
|
| 1371 |
+
shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
|
| 1372 |
+
cache format.
|
| 1373 |
+
|
| 1374 |
+
The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
|
| 1375 |
+
legacy cache format will be returned.
|
| 1376 |
+
|
| 1377 |
+
If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
|
| 1378 |
+
have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
|
| 1379 |
+
of shape `(batch_size, sequence_length)`.
|
| 1380 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
| 1381 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
| 1382 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
| 1383 |
+
model's internal embedding lookup matrix.
|
| 1384 |
+
use_cache (`bool`, *optional*):
|
| 1385 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
| 1386 |
+
`past_key_values`).
|
| 1387 |
+
output_attentions (`bool`, *optional*):
|
| 1388 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
| 1389 |
+
tensors for more detail.
|
| 1390 |
+
output_hidden_states (`bool`, *optional*):
|
| 1391 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
| 1392 |
+
more detail.
|
| 1393 |
+
return_dict (`bool`, *optional*):
|
| 1394 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
| 1395 |
+
"""
|
| 1396 |
+
|
| 1397 |
+
|
| 1398 |
+
@add_start_docstrings(
|
| 1399 |
+
"The bare DeepseekV2 Model outputting raw hidden-states without any specific head on top.",
|
| 1400 |
+
DeepseekV2_START_DOCSTRING,
|
| 1401 |
+
)
|
| 1402 |
+
class DeepseekV2Model(DeepseekV2PreTrainedModel):
|
| 1403 |
+
"""
|
| 1404 |
+
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`DeepseekV2DecoderLayer`]
|
| 1405 |
+
|
| 1406 |
+
Args:
|
| 1407 |
+
config: DeepseekV2Config
|
| 1408 |
+
"""
|
| 1409 |
+
|
| 1410 |
+
def __init__(self, config: DeepseekV2Config):
|
| 1411 |
+
super().__init__(config)
|
| 1412 |
+
self.padding_idx = config.pad_token_id
|
| 1413 |
+
self.vocab_size = config.vocab_size
|
| 1414 |
+
|
| 1415 |
+
self.embed_tokens = nn.Embedding(
|
| 1416 |
+
config.vocab_size, config.hidden_size, self.padding_idx
|
| 1417 |
+
)
|
| 1418 |
+
self.layers = nn.ModuleList(
|
| 1419 |
+
[
|
| 1420 |
+
DeepseekV2DecoderLayer(config, layer_idx)
|
| 1421 |
+
for layer_idx in range(config.num_hidden_layers)
|
| 1422 |
+
]
|
| 1423 |
+
)
|
| 1424 |
+
self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
|
| 1425 |
+
self.norm = DeepseekV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 1426 |
+
|
| 1427 |
+
self.gradient_checkpointing = False
|
| 1428 |
+
# Initialize weights and apply final processing
|
| 1429 |
+
self.post_init()
|
| 1430 |
+
|
| 1431 |
+
def get_input_embeddings(self):
|
| 1432 |
+
return self.embed_tokens
|
| 1433 |
+
|
| 1434 |
+
def set_input_embeddings(self, value):
|
| 1435 |
+
self.embed_tokens = value
|
| 1436 |
+
|
| 1437 |
+
@add_start_docstrings_to_model_forward(DeepseekV2_INPUTS_DOCSTRING)
|
| 1438 |
+
def forward(
|
| 1439 |
+
self,
|
| 1440 |
+
input_ids: torch.LongTensor = None,
|
| 1441 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1442 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1443 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1444 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1445 |
+
use_cache: Optional[bool] = None,
|
| 1446 |
+
output_attentions: Optional[bool] = None,
|
| 1447 |
+
output_hidden_states: Optional[bool] = None,
|
| 1448 |
+
return_dict: Optional[bool] = None,
|
| 1449 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
| 1450 |
+
output_attentions = (
|
| 1451 |
+
output_attentions
|
| 1452 |
+
if output_attentions is not None
|
| 1453 |
+
else self.config.output_attentions
|
| 1454 |
+
)
|
| 1455 |
+
output_hidden_states = (
|
| 1456 |
+
output_hidden_states
|
| 1457 |
+
if output_hidden_states is not None
|
| 1458 |
+
else self.config.output_hidden_states
|
| 1459 |
+
)
|
| 1460 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 1461 |
+
|
| 1462 |
+
return_dict = (
|
| 1463 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 1464 |
+
)
|
| 1465 |
+
|
| 1466 |
+
# retrieve input_ids and inputs_embeds
|
| 1467 |
+
if input_ids is not None and inputs_embeds is not None:
|
| 1468 |
+
raise ValueError(
|
| 1469 |
+
"You cannot specify both input_ids and inputs_embeds at the same time"
|
| 1470 |
+
)
|
| 1471 |
+
elif input_ids is not None:
|
| 1472 |
+
batch_size, seq_length = input_ids.shape[:2]
|
| 1473 |
+
elif inputs_embeds is not None:
|
| 1474 |
+
batch_size, seq_length = inputs_embeds.shape[:2]
|
| 1475 |
+
else:
|
| 1476 |
+
raise ValueError("You have to specify either input_ids or inputs_embeds")
|
| 1477 |
+
|
| 1478 |
+
if self.gradient_checkpointing and self.training:
|
| 1479 |
+
if use_cache:
|
| 1480 |
+
logger.warning_once(
|
| 1481 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`transformers."
|
| 1482 |
+
)
|
| 1483 |
+
use_cache = False
|
| 1484 |
+
|
| 1485 |
+
past_key_values_length = 0
|
| 1486 |
+
if use_cache:
|
| 1487 |
+
use_legacy_cache = not isinstance(past_key_values, Cache)
|
| 1488 |
+
if use_legacy_cache:
|
| 1489 |
+
past_key_values = DynamicCache.from_legacy_cache(past_key_values)
|
| 1490 |
+
past_key_values_length = past_key_values.get_usable_length(seq_length)
|
| 1491 |
+
|
| 1492 |
+
if position_ids is None:
|
| 1493 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
| 1494 |
+
position_ids = torch.arange(
|
| 1495 |
+
past_key_values_length,
|
| 1496 |
+
seq_length + past_key_values_length,
|
| 1497 |
+
dtype=torch.long,
|
| 1498 |
+
device=device,
|
| 1499 |
+
)
|
| 1500 |
+
position_ids = position_ids.unsqueeze(0)
|
| 1501 |
+
|
| 1502 |
+
if inputs_embeds is None:
|
| 1503 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 1504 |
+
|
| 1505 |
+
if self._use_flash_attention_2:
|
| 1506 |
+
# 2d mask is passed through the layers
|
| 1507 |
+
attention_mask = (
|
| 1508 |
+
attention_mask
|
| 1509 |
+
if (attention_mask is not None and 0 in attention_mask)
|
| 1510 |
+
else None
|
| 1511 |
+
)
|
| 1512 |
+
else:
|
| 1513 |
+
# 4d mask is passed through the layers
|
| 1514 |
+
attention_mask = _prepare_4d_causal_attention_mask(
|
| 1515 |
+
attention_mask,
|
| 1516 |
+
(batch_size, seq_length),
|
| 1517 |
+
inputs_embeds,
|
| 1518 |
+
past_key_values_length,
|
| 1519 |
+
)
|
| 1520 |
+
|
| 1521 |
+
# embed positions
|
| 1522 |
+
hidden_states = inputs_embeds
|
| 1523 |
+
|
| 1524 |
+
# decoder layers
|
| 1525 |
+
all_hidden_states = () if output_hidden_states else None
|
| 1526 |
+
all_self_attns = () if output_attentions else None
|
| 1527 |
+
next_decoder_cache = None
|
| 1528 |
+
|
| 1529 |
+
for decoder_layer in self.layers:
|
| 1530 |
+
if output_hidden_states:
|
| 1531 |
+
all_hidden_states += (hidden_states,)
|
| 1532 |
+
|
| 1533 |
+
if self.gradient_checkpointing and self.training:
|
| 1534 |
+
layer_outputs = self._gradient_checkpointing_func(
|
| 1535 |
+
decoder_layer.__call__,
|
| 1536 |
+
hidden_states,
|
| 1537 |
+
attention_mask,
|
| 1538 |
+
position_ids,
|
| 1539 |
+
past_key_values,
|
| 1540 |
+
output_attentions,
|
| 1541 |
+
use_cache,
|
| 1542 |
+
)
|
| 1543 |
+
else:
|
| 1544 |
+
layer_outputs = decoder_layer(
|
| 1545 |
+
hidden_states,
|
| 1546 |
+
attention_mask=attention_mask,
|
| 1547 |
+
position_ids=position_ids,
|
| 1548 |
+
past_key_value=past_key_values,
|
| 1549 |
+
output_attentions=output_attentions,
|
| 1550 |
+
use_cache=use_cache,
|
| 1551 |
+
)
|
| 1552 |
+
|
| 1553 |
+
hidden_states = layer_outputs[0]
|
| 1554 |
+
|
| 1555 |
+
if use_cache:
|
| 1556 |
+
next_decoder_cache = layer_outputs[2 if output_attentions else 1]
|
| 1557 |
+
|
| 1558 |
+
if output_attentions:
|
| 1559 |
+
all_self_attns += (layer_outputs[1],)
|
| 1560 |
+
|
| 1561 |
+
hidden_states = self.norm(hidden_states)
|
| 1562 |
+
|
| 1563 |
+
# add hidden states from the last decoder layer
|
| 1564 |
+
if output_hidden_states:
|
| 1565 |
+
all_hidden_states += (hidden_states,)
|
| 1566 |
+
|
| 1567 |
+
next_cache = None
|
| 1568 |
+
if use_cache:
|
| 1569 |
+
next_cache = (
|
| 1570 |
+
next_decoder_cache.to_legacy_cache()
|
| 1571 |
+
if use_legacy_cache
|
| 1572 |
+
else next_decoder_cache
|
| 1573 |
+
)
|
| 1574 |
+
if not return_dict:
|
| 1575 |
+
return tuple(
|
| 1576 |
+
v
|
| 1577 |
+
for v in [hidden_states, next_cache, all_hidden_states, all_self_attns]
|
| 1578 |
+
if v is not None
|
| 1579 |
+
)
|
| 1580 |
+
return BaseModelOutputWithPast(
|
| 1581 |
+
last_hidden_state=hidden_states,
|
| 1582 |
+
past_key_values=next_cache,
|
| 1583 |
+
hidden_states=all_hidden_states,
|
| 1584 |
+
attentions=all_self_attns,
|
| 1585 |
+
)
|
| 1586 |
+
|
| 1587 |
+
|
| 1588 |
+
from transformers.generation import GenerationMixin
|
| 1589 |
+
|
| 1590 |
+
class DeepseekV2ForCausalLM(DeepseekV2PreTrainedModel, GenerationMixin):
|
| 1591 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 1592 |
+
|
| 1593 |
+
def __init__(self, config):
|
| 1594 |
+
super().__init__(config)
|
| 1595 |
+
self.model = DeepseekV2Model(config)
|
| 1596 |
+
self.vocab_size = config.vocab_size
|
| 1597 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 1598 |
+
|
| 1599 |
+
# Initialize weights and apply final processing
|
| 1600 |
+
self.post_init()
|
| 1601 |
+
|
| 1602 |
+
def get_input_embeddings(self):
|
| 1603 |
+
return self.model.embed_tokens
|
| 1604 |
+
|
| 1605 |
+
def set_input_embeddings(self, value):
|
| 1606 |
+
self.model.embed_tokens = value
|
| 1607 |
+
|
| 1608 |
+
def get_output_embeddings(self):
|
| 1609 |
+
return self.lm_head
|
| 1610 |
+
|
| 1611 |
+
def set_output_embeddings(self, new_embeddings):
|
| 1612 |
+
self.lm_head = new_embeddings
|
| 1613 |
+
|
| 1614 |
+
def set_decoder(self, decoder):
|
| 1615 |
+
self.model = decoder
|
| 1616 |
+
|
| 1617 |
+
def get_decoder(self):
|
| 1618 |
+
return self.model
|
| 1619 |
+
|
| 1620 |
+
@add_start_docstrings_to_model_forward(DeepseekV2_INPUTS_DOCSTRING)
|
| 1621 |
+
@replace_return_docstrings(
|
| 1622 |
+
output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC
|
| 1623 |
+
)
|
| 1624 |
+
def forward(
|
| 1625 |
+
self,
|
| 1626 |
+
input_ids: torch.LongTensor = None,
|
| 1627 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1628 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1629 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1630 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1631 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1632 |
+
use_cache: Optional[bool] = None,
|
| 1633 |
+
output_attentions: Optional[bool] = None,
|
| 1634 |
+
output_hidden_states: Optional[bool] = None,
|
| 1635 |
+
return_dict: Optional[bool] = None,
|
| 1636 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
| 1637 |
+
r"""
|
| 1638 |
+
Args:
|
| 1639 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1640 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, transformers.,
|
| 1641 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 1642 |
+
(masked), the loss is only computed for the tokens with labels in `[0, transformers., config.vocab_size]`.
|
| 1643 |
+
|
| 1644 |
+
Returns:
|
| 1645 |
+
|
| 1646 |
+
Example:
|
| 1647 |
+
|
| 1648 |
+
```python
|
| 1649 |
+
>>> from transformers import AutoTokenizer, DeepseekV2ForCausalLM
|
| 1650 |
+
|
| 1651 |
+
>>> model = DeepseekV2ForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
|
| 1652 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
|
| 1653 |
+
|
| 1654 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
| 1655 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
| 1656 |
+
|
| 1657 |
+
>>> # Generate
|
| 1658 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 1659 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 1660 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
| 1661 |
+
```"""
|
| 1662 |
+
output_attentions = (
|
| 1663 |
+
output_attentions
|
| 1664 |
+
if output_attentions is not None
|
| 1665 |
+
else self.config.output_attentions
|
| 1666 |
+
)
|
| 1667 |
+
output_hidden_states = (
|
| 1668 |
+
output_hidden_states
|
| 1669 |
+
if output_hidden_states is not None
|
| 1670 |
+
else self.config.output_hidden_states
|
| 1671 |
+
)
|
| 1672 |
+
return_dict = (
|
| 1673 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 1674 |
+
)
|
| 1675 |
+
|
| 1676 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
| 1677 |
+
outputs = self.model(
|
| 1678 |
+
input_ids=input_ids,
|
| 1679 |
+
attention_mask=attention_mask,
|
| 1680 |
+
position_ids=position_ids,
|
| 1681 |
+
past_key_values=past_key_values,
|
| 1682 |
+
inputs_embeds=inputs_embeds,
|
| 1683 |
+
use_cache=use_cache,
|
| 1684 |
+
output_attentions=output_attentions,
|
| 1685 |
+
output_hidden_states=output_hidden_states,
|
| 1686 |
+
return_dict=return_dict,
|
| 1687 |
+
)
|
| 1688 |
+
|
| 1689 |
+
hidden_states = outputs[0]
|
| 1690 |
+
logits = self.lm_head(hidden_states)
|
| 1691 |
+
logits = logits.float()
|
| 1692 |
+
|
| 1693 |
+
loss = None
|
| 1694 |
+
if labels is not None:
|
| 1695 |
+
# Shift so that tokens < n predict n
|
| 1696 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 1697 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 1698 |
+
# Flatten the tokens
|
| 1699 |
+
loss_fct = CrossEntropyLoss()
|
| 1700 |
+
shift_logits = shift_logits.view(-1, self.config.vocab_size)
|
| 1701 |
+
shift_labels = shift_labels.view(-1)
|
| 1702 |
+
# Enable model parallelism
|
| 1703 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
| 1704 |
+
loss = loss_fct(shift_logits, shift_labels)
|
| 1705 |
+
|
| 1706 |
+
if not return_dict:
|
| 1707 |
+
output = (logits,) + outputs[1:]
|
| 1708 |
+
return (loss,) + output if loss is not None else output
|
| 1709 |
+
|
| 1710 |
+
return CausalLMOutputWithPast(
|
| 1711 |
+
loss=loss,
|
| 1712 |
+
logits=logits,
|
| 1713 |
+
past_key_values=outputs.past_key_values,
|
| 1714 |
+
hidden_states=outputs.hidden_states,
|
| 1715 |
+
attentions=outputs.attentions,
|
| 1716 |
+
)
|
| 1717 |
+
|
| 1718 |
+
def prepare_inputs_for_generation(
|
| 1719 |
+
self,
|
| 1720 |
+
input_ids,
|
| 1721 |
+
past_key_values=None,
|
| 1722 |
+
attention_mask=None,
|
| 1723 |
+
inputs_embeds=None,
|
| 1724 |
+
**kwargs,
|
| 1725 |
+
):
|
| 1726 |
+
if past_key_values is not None:
|
| 1727 |
+
if isinstance(past_key_values, Cache):
|
| 1728 |
+
cache_length = past_key_values.get_seq_length()
|
| 1729 |
+
past_length = past_key_values.seen_tokens
|
| 1730 |
+
max_cache_length = past_key_values.get_max_length()
|
| 1731 |
+
else:
|
| 1732 |
+
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1733 |
+
max_cache_length = None
|
| 1734 |
+
|
| 1735 |
+
# Keep only the unprocessed tokens:
|
| 1736 |
+
# 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
|
| 1737 |
+
# some of the inputs are exclusivelly passed as part of the cache (e.g. when passing input_embeds as
|
| 1738 |
+
# input)
|
| 1739 |
+
if (
|
| 1740 |
+
attention_mask is not None
|
| 1741 |
+
and attention_mask.shape[1] > input_ids.shape[1]
|
| 1742 |
+
):
|
| 1743 |
+
input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
|
| 1744 |
+
# 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
|
| 1745 |
+
# input_ids based on the past_length.
|
| 1746 |
+
elif past_length < input_ids.shape[1]:
|
| 1747 |
+
input_ids = input_ids[:, past_length:]
|
| 1748 |
+
# 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
|
| 1749 |
+
|
| 1750 |
+
# If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
|
| 1751 |
+
if (
|
| 1752 |
+
max_cache_length is not None
|
| 1753 |
+
and attention_mask is not None
|
| 1754 |
+
and cache_length + input_ids.shape[1] > max_cache_length
|
| 1755 |
+
):
|
| 1756 |
+
attention_mask = attention_mask[:, -max_cache_length:]
|
| 1757 |
+
|
| 1758 |
+
position_ids = kwargs.get("position_ids", None)
|
| 1759 |
+
if attention_mask is not None and position_ids is None:
|
| 1760 |
+
# create position_ids on the fly for batch generation
|
| 1761 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
| 1762 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 1763 |
+
if past_key_values:
|
| 1764 |
+
position_ids = position_ids[:, -input_ids.shape[1] :]
|
| 1765 |
+
|
| 1766 |
+
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
|
| 1767 |
+
if inputs_embeds is not None and past_key_values is None:
|
| 1768 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
| 1769 |
+
else:
|
| 1770 |
+
model_inputs = {"input_ids": input_ids}
|
| 1771 |
+
|
| 1772 |
+
model_inputs.update(
|
| 1773 |
+
{
|
| 1774 |
+
"position_ids": position_ids,
|
| 1775 |
+
"past_key_values": past_key_values,
|
| 1776 |
+
"use_cache": kwargs.get("use_cache"),
|
| 1777 |
+
"attention_mask": attention_mask,
|
| 1778 |
+
}
|
| 1779 |
+
)
|
| 1780 |
+
return model_inputs
|
| 1781 |
+
|
| 1782 |
+
@staticmethod
|
| 1783 |
+
def _reorder_cache(past_key_values, beam_idx):
|
| 1784 |
+
reordered_past = ()
|
| 1785 |
+
for layer_past in past_key_values:
|
| 1786 |
+
reordered_past += (
|
| 1787 |
+
tuple(
|
| 1788 |
+
past_state.index_select(0, beam_idx.to(past_state.device))
|
| 1789 |
+
for past_state in layer_past
|
| 1790 |
+
),
|
| 1791 |
+
)
|
| 1792 |
+
return reordered_past
|
| 1793 |
+
|
| 1794 |
+
|
| 1795 |
+
@add_start_docstrings(
|
| 1796 |
+
"""
|
| 1797 |
+
The DeepseekV2 Model transformer with a sequence classification head on top (linear layer).
|
| 1798 |
+
|
| 1799 |
+
[`DeepseekV2ForSequenceClassification`] uses the last token in order to do the classification, as other causal models
|
| 1800 |
+
(e.g. GPT-2) do.
|
| 1801 |
+
|
| 1802 |
+
Since it does classification on the last token, it requires to know the position of the last token. If a
|
| 1803 |
+
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
|
| 1804 |
+
no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
|
| 1805 |
+
padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
|
| 1806 |
+
each row of the batch).
|
| 1807 |
+
""",
|
| 1808 |
+
DeepseekV2_START_DOCSTRING,
|
| 1809 |
+
)
|
| 1810 |
+
class DeepseekV2ForSequenceClassification(DeepseekV2PreTrainedModel):
|
| 1811 |
+
def __init__(self, config):
|
| 1812 |
+
super().__init__(config)
|
| 1813 |
+
self.num_labels = config.num_labels
|
| 1814 |
+
self.model = DeepseekV2Model(config)
|
| 1815 |
+
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
|
| 1816 |
+
|
| 1817 |
+
# Initialize weights and apply final processing
|
| 1818 |
+
self.post_init()
|
| 1819 |
+
|
| 1820 |
+
def get_input_embeddings(self):
|
| 1821 |
+
return self.model.embed_tokens
|
| 1822 |
+
|
| 1823 |
+
def set_input_embeddings(self, value):
|
| 1824 |
+
self.model.embed_tokens = value
|
| 1825 |
+
|
| 1826 |
+
@add_start_docstrings_to_model_forward(DeepseekV2_INPUTS_DOCSTRING)
|
| 1827 |
+
def forward(
|
| 1828 |
+
self,
|
| 1829 |
+
input_ids: torch.LongTensor = None,
|
| 1830 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1831 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1832 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1833 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1834 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1835 |
+
use_cache: Optional[bool] = None,
|
| 1836 |
+
output_attentions: Optional[bool] = None,
|
| 1837 |
+
output_hidden_states: Optional[bool] = None,
|
| 1838 |
+
return_dict: Optional[bool] = None,
|
| 1839 |
+
) -> Union[Tuple, SequenceClassifierOutputWithPast]:
|
| 1840 |
+
r"""
|
| 1841 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 1842 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, transformers.,
|
| 1843 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
|
| 1844 |
+
`config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
| 1845 |
+
"""
|
| 1846 |
+
return_dict = (
|
| 1847 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 1848 |
+
)
|
| 1849 |
+
|
| 1850 |
+
transformer_outputs = self.model(
|
| 1851 |
+
input_ids,
|
| 1852 |
+
attention_mask=attention_mask,
|
| 1853 |
+
position_ids=position_ids,
|
| 1854 |
+
past_key_values=past_key_values,
|
| 1855 |
+
inputs_embeds=inputs_embeds,
|
| 1856 |
+
use_cache=use_cache,
|
| 1857 |
+
output_attentions=output_attentions,
|
| 1858 |
+
output_hidden_states=output_hidden_states,
|
| 1859 |
+
return_dict=return_dict,
|
| 1860 |
+
)
|
| 1861 |
+
hidden_states = transformer_outputs[0]
|
| 1862 |
+
logits = self.score(hidden_states)
|
| 1863 |
+
|
| 1864 |
+
if input_ids is not None:
|
| 1865 |
+
batch_size = input_ids.shape[0]
|
| 1866 |
+
else:
|
| 1867 |
+
batch_size = inputs_embeds.shape[0]
|
| 1868 |
+
|
| 1869 |
+
if self.config.pad_token_id is None and batch_size != 1:
|
| 1870 |
+
raise ValueError(
|
| 1871 |
+
"Cannot handle batch sizes > 1 if no padding token is defined."
|
| 1872 |
+
)
|
| 1873 |
+
if self.config.pad_token_id is None:
|
| 1874 |
+
sequence_lengths = -1
|
| 1875 |
+
else:
|
| 1876 |
+
if input_ids is not None:
|
| 1877 |
+
sequence_lengths = (
|
| 1878 |
+
torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
|
| 1879 |
+
).to(logits.device)
|
| 1880 |
+
else:
|
| 1881 |
+
sequence_lengths = -1
|
| 1882 |
+
|
| 1883 |
+
pooled_logits = logits[
|
| 1884 |
+
torch.arange(batch_size, device=logits.device), sequence_lengths
|
| 1885 |
+
]
|
| 1886 |
+
|
| 1887 |
+
loss = None
|
| 1888 |
+
if labels is not None:
|
| 1889 |
+
labels = labels.to(logits.device)
|
| 1890 |
+
if self.config.problem_type is None:
|
| 1891 |
+
if self.num_labels == 1:
|
| 1892 |
+
self.config.problem_type = "regression"
|
| 1893 |
+
elif self.num_labels > 1 and (
|
| 1894 |
+
labels.dtype == torch.long or labels.dtype == torch.int
|
| 1895 |
+
):
|
| 1896 |
+
self.config.problem_type = "single_label_classification"
|
| 1897 |
+
else:
|
| 1898 |
+
self.config.problem_type = "multi_label_classification"
|
| 1899 |
+
|
| 1900 |
+
if self.config.problem_type == "regression":
|
| 1901 |
+
loss_fct = MSELoss()
|
| 1902 |
+
if self.num_labels == 1:
|
| 1903 |
+
loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
|
| 1904 |
+
else:
|
| 1905 |
+
loss = loss_fct(pooled_logits, labels)
|
| 1906 |
+
elif self.config.problem_type == "single_label_classification":
|
| 1907 |
+
loss_fct = CrossEntropyLoss()
|
| 1908 |
+
loss = loss_fct(
|
| 1909 |
+
pooled_logits.view(-1, self.num_labels), labels.view(-1)
|
| 1910 |
+
)
|
| 1911 |
+
elif self.config.problem_type == "multi_label_classification":
|
| 1912 |
+
loss_fct = BCEWithLogitsLoss()
|
| 1913 |
+
loss = loss_fct(pooled_logits, labels)
|
| 1914 |
+
if not return_dict:
|
| 1915 |
+
output = (pooled_logits,) + transformer_outputs[1:]
|
| 1916 |
+
return ((loss,) + output) if loss is not None else output
|
| 1917 |
+
|
| 1918 |
+
return SequenceClassifierOutputWithPast(
|
| 1919 |
+
loss=loss,
|
| 1920 |
+
logits=pooled_logits,
|
| 1921 |
+
past_key_values=transformer_outputs.past_key_values,
|
| 1922 |
+
hidden_states=transformer_outputs.hidden_states,
|
| 1923 |
+
attentions=transformer_outputs.attentions,
|
| 1924 |
+
)
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
torch
|
| 3 |
+
transformers
|
| 4 |
+
requests
|
| 5 |
+
peft
|
| 6 |
+
accelerate
|
| 7 |
+
safetensors
|
| 8 |
+
huggingface_hub
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|begin▁of▁sentence|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": true,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|end▁of▁sentence|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": true,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<|end▁of▁sentence|>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": true,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
sunlight/index.html
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html>
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<title>Sunlight</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div id="container">
|
| 11 |
+
<div id="search-container">
|
| 12 |
+
<div id="search-bar-container">
|
| 13 |
+
<input type="text" id="search-bar" placeholder="Ask me anything...">
|
| 14 |
+
<div id="thinking-animation"></div>
|
| 15 |
+
</div>
|
| 16 |
+
</div>
|
| 17 |
+
<div id="results-container">
|
| 18 |
+
<webview id="webview" src="about:blank"></webview>
|
| 19 |
+
</div>
|
| 20 |
+
</div>
|
| 21 |
+
<script src="renderer.js"></script>
|
| 22 |
+
</body>
|
| 23 |
+
</html>
|
sunlight/main.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const { app, BrowserWindow } = require('electron');
|
| 3 |
+
const path = require('path');
|
| 4 |
+
|
| 5 |
+
function createWindow () {
|
| 6 |
+
const mainWindow = new BrowserWindow({
|
| 7 |
+
width: 800,
|
| 8 |
+
height: 600,
|
| 9 |
+
webPreferences: {
|
| 10 |
+
preload: path.join(__dirname, 'preload.js')
|
| 11 |
+
}
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
mainWindow.loadFile('index.html');
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
app.whenReady().then(() => {
|
| 18 |
+
createWindow();
|
| 19 |
+
|
| 20 |
+
app.on('activate', function () {
|
| 21 |
+
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
| 22 |
+
});
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
app.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
"electron": "^39.1.0"
|
| 13 |
+
}
|
| 14 |
+
},
|
| 15 |
+
"node_modules/@electron/get": {
|
| 16 |
+
"version": "2.0.3",
|
| 17 |
+
"resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz",
|
| 18 |
+
"integrity": "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ==",
|
| 19 |
+
"license": "MIT",
|
| 20 |
+
"dependencies": {
|
| 21 |
+
"debug": "^4.1.1",
|
| 22 |
+
"env-paths": "^2.2.0",
|
| 23 |
+
"fs-extra": "^8.1.0",
|
| 24 |
+
"got": "^11.8.5",
|
| 25 |
+
"progress": "^2.0.3",
|
| 26 |
+
"semver": "^6.2.0",
|
| 27 |
+
"sumchecker": "^3.0.1"
|
| 28 |
+
},
|
| 29 |
+
"engines": {
|
| 30 |
+
"node": ">=12"
|
| 31 |
+
},
|
| 32 |
+
"optionalDependencies": {
|
| 33 |
+
"global-agent": "^3.0.0"
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"node_modules/@sindresorhus/is": {
|
| 37 |
+
"version": "4.6.0",
|
| 38 |
+
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
|
| 39 |
+
"integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==",
|
| 40 |
+
"license": "MIT",
|
| 41 |
+
"engines": {
|
| 42 |
+
"node": ">=10"
|
| 43 |
+
},
|
| 44 |
+
"funding": {
|
| 45 |
+
"url": "https://github.com/sindresorhus/is?sponsor=1"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"node_modules/@szmarczak/http-timer": {
|
| 49 |
+
"version": "4.0.6",
|
| 50 |
+
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz",
|
| 51 |
+
"integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==",
|
| 52 |
+
"license": "MIT",
|
| 53 |
+
"dependencies": {
|
| 54 |
+
"defer-to-connect": "^2.0.0"
|
| 55 |
+
},
|
| 56 |
+
"engines": {
|
| 57 |
+
"node": ">=10"
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"node_modules/@types/cacheable-request": {
|
| 61 |
+
"version": "6.0.3",
|
| 62 |
+
"resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz",
|
| 63 |
+
"integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==",
|
| 64 |
+
"license": "MIT",
|
| 65 |
+
"dependencies": {
|
| 66 |
+
"@types/http-cache-semantics": "*",
|
| 67 |
+
"@types/keyv": "^3.1.4",
|
| 68 |
+
"@types/node": "*",
|
| 69 |
+
"@types/responselike": "^1.0.0"
|
| 70 |
+
}
|
| 71 |
+
},
|
| 72 |
+
"node_modules/@types/http-cache-semantics": {
|
| 73 |
+
"version": "4.0.4",
|
| 74 |
+
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
|
| 75 |
+
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==",
|
| 76 |
+
"license": "MIT"
|
| 77 |
+
},
|
| 78 |
+
"node_modules/@types/keyv": {
|
| 79 |
+
"version": "3.1.4",
|
| 80 |
+
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz",
|
| 81 |
+
"integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==",
|
| 82 |
+
"license": "MIT",
|
| 83 |
+
"dependencies": {
|
| 84 |
+
"@types/node": "*"
|
| 85 |
+
}
|
| 86 |
+
},
|
| 87 |
+
"node_modules/@types/node": {
|
| 88 |
+
"version": "22.19.0",
|
| 89 |
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.0.tgz",
|
| 90 |
+
"integrity": "sha512-xpr/lmLPQEj+TUnHmR+Ab91/glhJvsqcjB+yY0Ix9GO70H6Lb4FHH5GeqdOE5btAx7eIMwuHkp4H2MSkLcqWbA==",
|
| 91 |
+
"license": "MIT",
|
| 92 |
+
"dependencies": {
|
| 93 |
+
"undici-types": "~6.21.0"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"node_modules/@types/responselike": {
|
| 97 |
+
"version": "1.0.3",
|
| 98 |
+
"resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz",
|
| 99 |
+
"integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==",
|
| 100 |
+
"license": "MIT",
|
| 101 |
+
"dependencies": {
|
| 102 |
+
"@types/node": "*"
|
| 103 |
+
}
|
| 104 |
+
},
|
| 105 |
+
"node_modules/@types/yauzl": {
|
| 106 |
+
"version": "2.10.3",
|
| 107 |
+
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz",
|
| 108 |
+
"integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==",
|
| 109 |
+
"license": "MIT",
|
| 110 |
+
"optional": true,
|
| 111 |
+
"dependencies": {
|
| 112 |
+
"@types/node": "*"
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"node_modules/boolean": {
|
| 116 |
+
"version": "3.2.0",
|
| 117 |
+
"resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz",
|
| 118 |
+
"integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==",
|
| 119 |
+
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
|
| 120 |
+
"license": "MIT",
|
| 121 |
+
"optional": true
|
| 122 |
+
},
|
| 123 |
+
"node_modules/buffer-crc32": {
|
| 124 |
+
"version": "0.2.13",
|
| 125 |
+
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
| 126 |
+
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
|
| 127 |
+
"license": "MIT",
|
| 128 |
+
"engines": {
|
| 129 |
+
"node": "*"
|
| 130 |
+
}
|
| 131 |
+
},
|
| 132 |
+
"node_modules/cacheable-lookup": {
|
| 133 |
+
"version": "5.0.4",
|
| 134 |
+
"resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz",
|
| 135 |
+
"integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==",
|
| 136 |
+
"license": "MIT",
|
| 137 |
+
"engines": {
|
| 138 |
+
"node": ">=10.6.0"
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
"node_modules/cacheable-request": {
|
| 142 |
+
"version": "7.0.4",
|
| 143 |
+
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz",
|
| 144 |
+
"integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==",
|
| 145 |
+
"license": "MIT",
|
| 146 |
+
"dependencies": {
|
| 147 |
+
"clone-response": "^1.0.2",
|
| 148 |
+
"get-stream": "^5.1.0",
|
| 149 |
+
"http-cache-semantics": "^4.0.0",
|
| 150 |
+
"keyv": "^4.0.0",
|
| 151 |
+
"lowercase-keys": "^2.0.0",
|
| 152 |
+
"normalize-url": "^6.0.1",
|
| 153 |
+
"responselike": "^2.0.0"
|
| 154 |
+
},
|
| 155 |
+
"engines": {
|
| 156 |
+
"node": ">=8"
|
| 157 |
+
}
|
| 158 |
+
},
|
| 159 |
+
"node_modules/clone-response": {
|
| 160 |
+
"version": "1.0.3",
|
| 161 |
+
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz",
|
| 162 |
+
"integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==",
|
| 163 |
+
"license": "MIT",
|
| 164 |
+
"dependencies": {
|
| 165 |
+
"mimic-response": "^1.0.0"
|
| 166 |
+
},
|
| 167 |
+
"funding": {
|
| 168 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 169 |
+
}
|
| 170 |
+
},
|
| 171 |
+
"node_modules/debug": {
|
| 172 |
+
"version": "4.4.3",
|
| 173 |
+
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
| 174 |
+
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
| 175 |
+
"license": "MIT",
|
| 176 |
+
"dependencies": {
|
| 177 |
+
"ms": "^2.1.3"
|
| 178 |
+
},
|
| 179 |
+
"engines": {
|
| 180 |
+
"node": ">=6.0"
|
| 181 |
+
},
|
| 182 |
+
"peerDependenciesMeta": {
|
| 183 |
+
"supports-color": {
|
| 184 |
+
"optional": true
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
},
|
| 188 |
+
"node_modules/decompress-response": {
|
| 189 |
+
"version": "6.0.0",
|
| 190 |
+
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
|
| 191 |
+
"integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
|
| 192 |
+
"license": "MIT",
|
| 193 |
+
"dependencies": {
|
| 194 |
+
"mimic-response": "^3.1.0"
|
| 195 |
+
},
|
| 196 |
+
"engines": {
|
| 197 |
+
"node": ">=10"
|
| 198 |
+
},
|
| 199 |
+
"funding": {
|
| 200 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 201 |
+
}
|
| 202 |
+
},
|
| 203 |
+
"node_modules/decompress-response/node_modules/mimic-response": {
|
| 204 |
+
"version": "3.1.0",
|
| 205 |
+
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
|
| 206 |
+
"integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==",
|
| 207 |
+
"license": "MIT",
|
| 208 |
+
"engines": {
|
| 209 |
+
"node": ">=10"
|
| 210 |
+
},
|
| 211 |
+
"funding": {
|
| 212 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 213 |
+
}
|
| 214 |
+
},
|
| 215 |
+
"node_modules/defer-to-connect": {
|
| 216 |
+
"version": "2.0.1",
|
| 217 |
+
"resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz",
|
| 218 |
+
"integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==",
|
| 219 |
+
"license": "MIT",
|
| 220 |
+
"engines": {
|
| 221 |
+
"node": ">=10"
|
| 222 |
+
}
|
| 223 |
+
},
|
| 224 |
+
"node_modules/define-data-property": {
|
| 225 |
+
"version": "1.1.4",
|
| 226 |
+
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
|
| 227 |
+
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
|
| 228 |
+
"license": "MIT",
|
| 229 |
+
"optional": true,
|
| 230 |
+
"dependencies": {
|
| 231 |
+
"es-define-property": "^1.0.0",
|
| 232 |
+
"es-errors": "^1.3.0",
|
| 233 |
+
"gopd": "^1.0.1"
|
| 234 |
+
},
|
| 235 |
+
"engines": {
|
| 236 |
+
"node": ">= 0.4"
|
| 237 |
+
},
|
| 238 |
+
"funding": {
|
| 239 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 240 |
+
}
|
| 241 |
+
},
|
| 242 |
+
"node_modules/define-properties": {
|
| 243 |
+
"version": "1.2.1",
|
| 244 |
+
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
|
| 245 |
+
"integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
|
| 246 |
+
"license": "MIT",
|
| 247 |
+
"optional": true,
|
| 248 |
+
"dependencies": {
|
| 249 |
+
"define-data-property": "^1.0.1",
|
| 250 |
+
"has-property-descriptors": "^1.0.0",
|
| 251 |
+
"object-keys": "^1.1.1"
|
| 252 |
+
},
|
| 253 |
+
"engines": {
|
| 254 |
+
"node": ">= 0.4"
|
| 255 |
+
},
|
| 256 |
+
"funding": {
|
| 257 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 258 |
+
}
|
| 259 |
+
},
|
| 260 |
+
"node_modules/detect-node": {
|
| 261 |
+
"version": "2.1.0",
|
| 262 |
+
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz",
|
| 263 |
+
"integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==",
|
| 264 |
+
"license": "MIT",
|
| 265 |
+
"optional": true
|
| 266 |
+
},
|
| 267 |
+
"node_modules/electron": {
|
| 268 |
+
"version": "39.1.0",
|
| 269 |
+
"resolved": "https://registry.npmjs.org/electron/-/electron-39.1.0.tgz",
|
| 270 |
+
"integrity": "sha512-vPRbKKQUzKWZZX68fuYdz4iS/eavGcQkHOGK4ylv0YJLbBRxxUlflPRdqRGflFjwid+sja7gbNul2lArevYwrw==",
|
| 271 |
+
"hasInstallScript": true,
|
| 272 |
+
"license": "MIT",
|
| 273 |
+
"dependencies": {
|
| 274 |
+
"@electron/get": "^2.0.0",
|
| 275 |
+
"@types/node": "^22.7.7",
|
| 276 |
+
"extract-zip": "^2.0.1"
|
| 277 |
+
},
|
| 278 |
+
"bin": {
|
| 279 |
+
"electron": "cli.js"
|
| 280 |
+
},
|
| 281 |
+
"engines": {
|
| 282 |
+
"node": ">= 12.20.55"
|
| 283 |
+
}
|
| 284 |
+
},
|
| 285 |
+
"node_modules/end-of-stream": {
|
| 286 |
+
"version": "1.4.5",
|
| 287 |
+
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
| 288 |
+
"integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
|
| 289 |
+
"license": "MIT",
|
| 290 |
+
"dependencies": {
|
| 291 |
+
"once": "^1.4.0"
|
| 292 |
+
}
|
| 293 |
+
},
|
| 294 |
+
"node_modules/env-paths": {
|
| 295 |
+
"version": "2.2.1",
|
| 296 |
+
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
|
| 297 |
+
"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",
|
| 298 |
+
"license": "MIT",
|
| 299 |
+
"engines": {
|
| 300 |
+
"node": ">=6"
|
| 301 |
+
}
|
| 302 |
+
},
|
| 303 |
+
"node_modules/es-define-property": {
|
| 304 |
+
"version": "1.0.1",
|
| 305 |
+
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
| 306 |
+
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
| 307 |
+
"license": "MIT",
|
| 308 |
+
"optional": true,
|
| 309 |
+
"engines": {
|
| 310 |
+
"node": ">= 0.4"
|
| 311 |
+
}
|
| 312 |
+
},
|
| 313 |
+
"node_modules/es-errors": {
|
| 314 |
+
"version": "1.3.0",
|
| 315 |
+
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
| 316 |
+
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
| 317 |
+
"license": "MIT",
|
| 318 |
+
"optional": true,
|
| 319 |
+
"engines": {
|
| 320 |
+
"node": ">= 0.4"
|
| 321 |
+
}
|
| 322 |
+
},
|
| 323 |
+
"node_modules/es6-error": {
|
| 324 |
+
"version": "4.1.1",
|
| 325 |
+
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
|
| 326 |
+
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
|
| 327 |
+
"license": "MIT",
|
| 328 |
+
"optional": true
|
| 329 |
+
},
|
| 330 |
+
"node_modules/escape-string-regexp": {
|
| 331 |
+
"version": "4.0.0",
|
| 332 |
+
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
| 333 |
+
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
| 334 |
+
"license": "MIT",
|
| 335 |
+
"optional": true,
|
| 336 |
+
"engines": {
|
| 337 |
+
"node": ">=10"
|
| 338 |
+
},
|
| 339 |
+
"funding": {
|
| 340 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 341 |
+
}
|
| 342 |
+
},
|
| 343 |
+
"node_modules/extract-zip": {
|
| 344 |
+
"version": "2.0.1",
|
| 345 |
+
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
|
| 346 |
+
"integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==",
|
| 347 |
+
"license": "BSD-2-Clause",
|
| 348 |
+
"dependencies": {
|
| 349 |
+
"debug": "^4.1.1",
|
| 350 |
+
"get-stream": "^5.1.0",
|
| 351 |
+
"yauzl": "^2.10.0"
|
| 352 |
+
},
|
| 353 |
+
"bin": {
|
| 354 |
+
"extract-zip": "cli.js"
|
| 355 |
+
},
|
| 356 |
+
"engines": {
|
| 357 |
+
"node": ">= 10.17.0"
|
| 358 |
+
},
|
| 359 |
+
"optionalDependencies": {
|
| 360 |
+
"@types/yauzl": "^2.9.1"
|
| 361 |
+
}
|
| 362 |
+
},
|
| 363 |
+
"node_modules/fd-slicer": {
|
| 364 |
+
"version": "1.1.0",
|
| 365 |
+
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
|
| 366 |
+
"integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==",
|
| 367 |
+
"license": "MIT",
|
| 368 |
+
"dependencies": {
|
| 369 |
+
"pend": "~1.2.0"
|
| 370 |
+
}
|
| 371 |
+
},
|
| 372 |
+
"node_modules/fs-extra": {
|
| 373 |
+
"version": "8.1.0",
|
| 374 |
+
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
|
| 375 |
+
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
|
| 376 |
+
"license": "MIT",
|
| 377 |
+
"dependencies": {
|
| 378 |
+
"graceful-fs": "^4.2.0",
|
| 379 |
+
"jsonfile": "^4.0.0",
|
| 380 |
+
"universalify": "^0.1.0"
|
| 381 |
+
},
|
| 382 |
+
"engines": {
|
| 383 |
+
"node": ">=6 <7 || >=8"
|
| 384 |
+
}
|
| 385 |
+
},
|
| 386 |
+
"node_modules/get-stream": {
|
| 387 |
+
"version": "5.2.0",
|
| 388 |
+
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
|
| 389 |
+
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
|
| 390 |
+
"license": "MIT",
|
| 391 |
+
"dependencies": {
|
| 392 |
+
"pump": "^3.0.0"
|
| 393 |
+
},
|
| 394 |
+
"engines": {
|
| 395 |
+
"node": ">=8"
|
| 396 |
+
},
|
| 397 |
+
"funding": {
|
| 398 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 399 |
+
}
|
| 400 |
+
},
|
| 401 |
+
"node_modules/global-agent": {
|
| 402 |
+
"version": "3.0.0",
|
| 403 |
+
"resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz",
|
| 404 |
+
"integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==",
|
| 405 |
+
"license": "BSD-3-Clause",
|
| 406 |
+
"optional": true,
|
| 407 |
+
"dependencies": {
|
| 408 |
+
"boolean": "^3.0.1",
|
| 409 |
+
"es6-error": "^4.1.1",
|
| 410 |
+
"matcher": "^3.0.0",
|
| 411 |
+
"roarr": "^2.15.3",
|
| 412 |
+
"semver": "^7.3.2",
|
| 413 |
+
"serialize-error": "^7.0.1"
|
| 414 |
+
},
|
| 415 |
+
"engines": {
|
| 416 |
+
"node": ">=10.0"
|
| 417 |
+
}
|
| 418 |
+
},
|
| 419 |
+
"node_modules/global-agent/node_modules/semver": {
|
| 420 |
+
"version": "7.7.3",
|
| 421 |
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
| 422 |
+
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
| 423 |
+
"license": "ISC",
|
| 424 |
+
"optional": true,
|
| 425 |
+
"bin": {
|
| 426 |
+
"semver": "bin/semver.js"
|
| 427 |
+
},
|
| 428 |
+
"engines": {
|
| 429 |
+
"node": ">=10"
|
| 430 |
+
}
|
| 431 |
+
},
|
| 432 |
+
"node_modules/globalthis": {
|
| 433 |
+
"version": "1.0.4",
|
| 434 |
+
"resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz",
|
| 435 |
+
"integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==",
|
| 436 |
+
"license": "MIT",
|
| 437 |
+
"optional": true,
|
| 438 |
+
"dependencies": {
|
| 439 |
+
"define-properties": "^1.2.1",
|
| 440 |
+
"gopd": "^1.0.1"
|
| 441 |
+
},
|
| 442 |
+
"engines": {
|
| 443 |
+
"node": ">= 0.4"
|
| 444 |
+
},
|
| 445 |
+
"funding": {
|
| 446 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 447 |
+
}
|
| 448 |
+
},
|
| 449 |
+
"node_modules/gopd": {
|
| 450 |
+
"version": "1.2.0",
|
| 451 |
+
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
| 452 |
+
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
| 453 |
+
"license": "MIT",
|
| 454 |
+
"optional": true,
|
| 455 |
+
"engines": {
|
| 456 |
+
"node": ">= 0.4"
|
| 457 |
+
},
|
| 458 |
+
"funding": {
|
| 459 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 460 |
+
}
|
| 461 |
+
},
|
| 462 |
+
"node_modules/got": {
|
| 463 |
+
"version": "11.8.6",
|
| 464 |
+
"resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz",
|
| 465 |
+
"integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==",
|
| 466 |
+
"license": "MIT",
|
| 467 |
+
"dependencies": {
|
| 468 |
+
"@sindresorhus/is": "^4.0.0",
|
| 469 |
+
"@szmarczak/http-timer": "^4.0.5",
|
| 470 |
+
"@types/cacheable-request": "^6.0.1",
|
| 471 |
+
"@types/responselike": "^1.0.0",
|
| 472 |
+
"cacheable-lookup": "^5.0.3",
|
| 473 |
+
"cacheable-request": "^7.0.2",
|
| 474 |
+
"decompress-response": "^6.0.0",
|
| 475 |
+
"http2-wrapper": "^1.0.0-beta.5.2",
|
| 476 |
+
"lowercase-keys": "^2.0.0",
|
| 477 |
+
"p-cancelable": "^2.0.0",
|
| 478 |
+
"responselike": "^2.0.0"
|
| 479 |
+
},
|
| 480 |
+
"engines": {
|
| 481 |
+
"node": ">=10.19.0"
|
| 482 |
+
},
|
| 483 |
+
"funding": {
|
| 484 |
+
"url": "https://github.com/sindresorhus/got?sponsor=1"
|
| 485 |
+
}
|
| 486 |
+
},
|
| 487 |
+
"node_modules/graceful-fs": {
|
| 488 |
+
"version": "4.2.11",
|
| 489 |
+
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
| 490 |
+
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
| 491 |
+
"license": "ISC"
|
| 492 |
+
},
|
| 493 |
+
"node_modules/has-property-descriptors": {
|
| 494 |
+
"version": "1.0.2",
|
| 495 |
+
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
|
| 496 |
+
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
|
| 497 |
+
"license": "MIT",
|
| 498 |
+
"optional": true,
|
| 499 |
+
"dependencies": {
|
| 500 |
+
"es-define-property": "^1.0.0"
|
| 501 |
+
},
|
| 502 |
+
"funding": {
|
| 503 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 504 |
+
}
|
| 505 |
+
},
|
| 506 |
+
"node_modules/http-cache-semantics": {
|
| 507 |
+
"version": "4.2.0",
|
| 508 |
+
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz",
|
| 509 |
+
"integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==",
|
| 510 |
+
"license": "BSD-2-Clause"
|
| 511 |
+
},
|
| 512 |
+
"node_modules/http2-wrapper": {
|
| 513 |
+
"version": "1.0.3",
|
| 514 |
+
"resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz",
|
| 515 |
+
"integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==",
|
| 516 |
+
"license": "MIT",
|
| 517 |
+
"dependencies": {
|
| 518 |
+
"quick-lru": "^5.1.1",
|
| 519 |
+
"resolve-alpn": "^1.0.0"
|
| 520 |
+
},
|
| 521 |
+
"engines": {
|
| 522 |
+
"node": ">=10.19.0"
|
| 523 |
+
}
|
| 524 |
+
},
|
| 525 |
+
"node_modules/json-buffer": {
|
| 526 |
+
"version": "3.0.1",
|
| 527 |
+
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
|
| 528 |
+
"integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==",
|
| 529 |
+
"license": "MIT"
|
| 530 |
+
},
|
| 531 |
+
"node_modules/json-stringify-safe": {
|
| 532 |
+
"version": "5.0.1",
|
| 533 |
+
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
| 534 |
+
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==",
|
| 535 |
+
"license": "ISC",
|
| 536 |
+
"optional": true
|
| 537 |
+
},
|
| 538 |
+
"node_modules/jsonfile": {
|
| 539 |
+
"version": "4.0.0",
|
| 540 |
+
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
| 541 |
+
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
|
| 542 |
+
"license": "MIT",
|
| 543 |
+
"optionalDependencies": {
|
| 544 |
+
"graceful-fs": "^4.1.6"
|
| 545 |
+
}
|
| 546 |
+
},
|
| 547 |
+
"node_modules/keyv": {
|
| 548 |
+
"version": "4.5.4",
|
| 549 |
+
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
| 550 |
+
"integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==",
|
| 551 |
+
"license": "MIT",
|
| 552 |
+
"dependencies": {
|
| 553 |
+
"json-buffer": "3.0.1"
|
| 554 |
+
}
|
| 555 |
+
},
|
| 556 |
+
"node_modules/lowercase-keys": {
|
| 557 |
+
"version": "2.0.0",
|
| 558 |
+
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
|
| 559 |
+
"integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==",
|
| 560 |
+
"license": "MIT",
|
| 561 |
+
"engines": {
|
| 562 |
+
"node": ">=8"
|
| 563 |
+
}
|
| 564 |
+
},
|
| 565 |
+
"node_modules/matcher": {
|
| 566 |
+
"version": "3.0.0",
|
| 567 |
+
"resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz",
|
| 568 |
+
"integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
|
| 569 |
+
"license": "MIT",
|
| 570 |
+
"optional": true,
|
| 571 |
+
"dependencies": {
|
| 572 |
+
"escape-string-regexp": "^4.0.0"
|
| 573 |
+
},
|
| 574 |
+
"engines": {
|
| 575 |
+
"node": ">=10"
|
| 576 |
+
}
|
| 577 |
+
},
|
| 578 |
+
"node_modules/mimic-response": {
|
| 579 |
+
"version": "1.0.1",
|
| 580 |
+
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
|
| 581 |
+
"integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==",
|
| 582 |
+
"license": "MIT",
|
| 583 |
+
"engines": {
|
| 584 |
+
"node": ">=4"
|
| 585 |
+
}
|
| 586 |
+
},
|
| 587 |
+
"node_modules/ms": {
|
| 588 |
+
"version": "2.1.3",
|
| 589 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
| 590 |
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
| 591 |
+
"license": "MIT"
|
| 592 |
+
},
|
| 593 |
+
"node_modules/normalize-url": {
|
| 594 |
+
"version": "6.1.0",
|
| 595 |
+
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz",
|
| 596 |
+
"integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==",
|
| 597 |
+
"license": "MIT",
|
| 598 |
+
"engines": {
|
| 599 |
+
"node": ">=10"
|
| 600 |
+
},
|
| 601 |
+
"funding": {
|
| 602 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 603 |
+
}
|
| 604 |
+
},
|
| 605 |
+
"node_modules/object-keys": {
|
| 606 |
+
"version": "1.1.1",
|
| 607 |
+
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
| 608 |
+
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
| 609 |
+
"license": "MIT",
|
| 610 |
+
"optional": true,
|
| 611 |
+
"engines": {
|
| 612 |
+
"node": ">= 0.4"
|
| 613 |
+
}
|
| 614 |
+
},
|
| 615 |
+
"node_modules/once": {
|
| 616 |
+
"version": "1.4.0",
|
| 617 |
+
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
| 618 |
+
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
| 619 |
+
"license": "ISC",
|
| 620 |
+
"dependencies": {
|
| 621 |
+
"wrappy": "1"
|
| 622 |
+
}
|
| 623 |
+
},
|
| 624 |
+
"node_modules/p-cancelable": {
|
| 625 |
+
"version": "2.1.1",
|
| 626 |
+
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz",
|
| 627 |
+
"integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==",
|
| 628 |
+
"license": "MIT",
|
| 629 |
+
"engines": {
|
| 630 |
+
"node": ">=8"
|
| 631 |
+
}
|
| 632 |
+
},
|
| 633 |
+
"node_modules/pend": {
|
| 634 |
+
"version": "1.2.0",
|
| 635 |
+
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
|
| 636 |
+
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
| 637 |
+
"license": "MIT"
|
| 638 |
+
},
|
| 639 |
+
"node_modules/progress": {
|
| 640 |
+
"version": "2.0.3",
|
| 641 |
+
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
|
| 642 |
+
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
|
| 643 |
+
"license": "MIT",
|
| 644 |
+
"engines": {
|
| 645 |
+
"node": ">=0.4.0"
|
| 646 |
+
}
|
| 647 |
+
},
|
| 648 |
+
"node_modules/pump": {
|
| 649 |
+
"version": "3.0.3",
|
| 650 |
+
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz",
|
| 651 |
+
"integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==",
|
| 652 |
+
"license": "MIT",
|
| 653 |
+
"dependencies": {
|
| 654 |
+
"end-of-stream": "^1.1.0",
|
| 655 |
+
"once": "^1.3.1"
|
| 656 |
+
}
|
| 657 |
+
},
|
| 658 |
+
"node_modules/quick-lru": {
|
| 659 |
+
"version": "5.1.1",
|
| 660 |
+
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
|
| 661 |
+
"integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==",
|
| 662 |
+
"license": "MIT",
|
| 663 |
+
"engines": {
|
| 664 |
+
"node": ">=10"
|
| 665 |
+
},
|
| 666 |
+
"funding": {
|
| 667 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 668 |
+
}
|
| 669 |
+
},
|
| 670 |
+
"node_modules/resolve-alpn": {
|
| 671 |
+
"version": "1.2.1",
|
| 672 |
+
"resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
|
| 673 |
+
"integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==",
|
| 674 |
+
"license": "MIT"
|
| 675 |
+
},
|
| 676 |
+
"node_modules/responselike": {
|
| 677 |
+
"version": "2.0.1",
|
| 678 |
+
"resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz",
|
| 679 |
+
"integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==",
|
| 680 |
+
"license": "MIT",
|
| 681 |
+
"dependencies": {
|
| 682 |
+
"lowercase-keys": "^2.0.0"
|
| 683 |
+
},
|
| 684 |
+
"funding": {
|
| 685 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 686 |
+
}
|
| 687 |
+
},
|
| 688 |
+
"node_modules/roarr": {
|
| 689 |
+
"version": "2.15.4",
|
| 690 |
+
"resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz",
|
| 691 |
+
"integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==",
|
| 692 |
+
"license": "BSD-3-Clause",
|
| 693 |
+
"optional": true,
|
| 694 |
+
"dependencies": {
|
| 695 |
+
"boolean": "^3.0.1",
|
| 696 |
+
"detect-node": "^2.0.4",
|
| 697 |
+
"globalthis": "^1.0.1",
|
| 698 |
+
"json-stringify-safe": "^5.0.1",
|
| 699 |
+
"semver-compare": "^1.0.0",
|
| 700 |
+
"sprintf-js": "^1.1.2"
|
| 701 |
+
},
|
| 702 |
+
"engines": {
|
| 703 |
+
"node": ">=8.0"
|
| 704 |
+
}
|
| 705 |
+
},
|
| 706 |
+
"node_modules/semver": {
|
| 707 |
+
"version": "6.3.1",
|
| 708 |
+
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
| 709 |
+
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
| 710 |
+
"license": "ISC",
|
| 711 |
+
"bin": {
|
| 712 |
+
"semver": "bin/semver.js"
|
| 713 |
+
}
|
| 714 |
+
},
|
| 715 |
+
"node_modules/semver-compare": {
|
| 716 |
+
"version": "1.0.0",
|
| 717 |
+
"resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz",
|
| 718 |
+
"integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==",
|
| 719 |
+
"license": "MIT",
|
| 720 |
+
"optional": true
|
| 721 |
+
},
|
| 722 |
+
"node_modules/serialize-error": {
|
| 723 |
+
"version": "7.0.1",
|
| 724 |
+
"resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz",
|
| 725 |
+
"integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==",
|
| 726 |
+
"license": "MIT",
|
| 727 |
+
"optional": true,
|
| 728 |
+
"dependencies": {
|
| 729 |
+
"type-fest": "^0.13.1"
|
| 730 |
+
},
|
| 731 |
+
"engines": {
|
| 732 |
+
"node": ">=10"
|
| 733 |
+
},
|
| 734 |
+
"funding": {
|
| 735 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 736 |
+
}
|
| 737 |
+
},
|
| 738 |
+
"node_modules/sprintf-js": {
|
| 739 |
+
"version": "1.1.3",
|
| 740 |
+
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
|
| 741 |
+
"integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
|
| 742 |
+
"license": "BSD-3-Clause",
|
| 743 |
+
"optional": true
|
| 744 |
+
},
|
| 745 |
+
"node_modules/sumchecker": {
|
| 746 |
+
"version": "3.0.1",
|
| 747 |
+
"resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz",
|
| 748 |
+
"integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==",
|
| 749 |
+
"license": "Apache-2.0",
|
| 750 |
+
"dependencies": {
|
| 751 |
+
"debug": "^4.1.0"
|
| 752 |
+
},
|
| 753 |
+
"engines": {
|
| 754 |
+
"node": ">= 8.0"
|
| 755 |
+
}
|
| 756 |
+
},
|
| 757 |
+
"node_modules/type-fest": {
|
| 758 |
+
"version": "0.13.1",
|
| 759 |
+
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",
|
| 760 |
+
"integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==",
|
| 761 |
+
"license": "(MIT OR CC0-1.0)",
|
| 762 |
+
"optional": true,
|
| 763 |
+
"engines": {
|
| 764 |
+
"node": ">=10"
|
| 765 |
+
},
|
| 766 |
+
"funding": {
|
| 767 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 768 |
+
}
|
| 769 |
+
},
|
| 770 |
+
"node_modules/undici-types": {
|
| 771 |
+
"version": "6.21.0",
|
| 772 |
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
| 773 |
+
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
| 774 |
+
"license": "MIT"
|
| 775 |
+
},
|
| 776 |
+
"node_modules/universalify": {
|
| 777 |
+
"version": "0.1.2",
|
| 778 |
+
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
| 779 |
+
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
|
| 780 |
+
"license": "MIT",
|
| 781 |
+
"engines": {
|
| 782 |
+
"node": ">= 4.0.0"
|
| 783 |
+
}
|
| 784 |
+
},
|
| 785 |
+
"node_modules/wrappy": {
|
| 786 |
+
"version": "1.0.2",
|
| 787 |
+
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
| 788 |
+
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
| 789 |
+
"license": "ISC"
|
| 790 |
+
},
|
| 791 |
+
"node_modules/yauzl": {
|
| 792 |
+
"version": "2.10.0",
|
| 793 |
+
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
| 794 |
+
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
|
| 795 |
+
"license": "MIT",
|
| 796 |
+
"dependencies": {
|
| 797 |
+
"buffer-crc32": "~0.2.3",
|
| 798 |
+
"fd-slicer": "~1.1.0"
|
| 799 |
+
}
|
| 800 |
+
}
|
| 801 |
+
}
|
| 802 |
+
}
|
sunlight/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "sunlight",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "A web browser with an AI-powered search engine.",
|
| 5 |
+
"main": "main.js",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"start": "electron .",
|
| 8 |
+
"test": "echo \"Error: no test specified\" && exit 1"
|
| 9 |
+
},
|
| 10 |
+
"keywords": [],
|
| 11 |
+
"author": "",
|
| 12 |
+
"license": "ISC",
|
| 13 |
+
"dependencies": {
|
| 14 |
+
"electron": "^39.1.0"
|
| 15 |
+
}
|
| 16 |
+
}
|
sunlight/preload.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
// preload.js
|
sunlight/renderer.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const searchBar = document.getElementById('search-bar');
|
| 3 |
+
const searchButton = document.getElementById('search-button');
|
| 4 |
+
const webview = document.getElementById('webview');
|
| 5 |
+
|
| 6 |
+
searchButton.addEventListener('click', () => {
|
| 7 |
+
const query = searchBar.value;
|
| 8 |
+
if (query.startsWith('http') || query.startsWith('www')) {
|
| 9 |
+
webview.src = query;
|
| 10 |
+
} else {
|
| 11 |
+
// In the future, this will be replaced with the Sunlight search engine
|
| 12 |
+
webview.src = `https://www.google.com/search?q=${query}`;
|
| 13 |
+
}
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
searchBar.addEventListener('keydown', (e) => {
|
| 17 |
+
if (e.key === 'Enter') {
|
| 18 |
+
searchButton.click();
|
| 19 |
+
}
|
| 20 |
+
});
|
sunlight/style.css
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
body {
|
| 3 |
+
font-family: sans-serif;
|
| 4 |
+
margin: 0;
|
| 5 |
+
display: flex;
|
| 6 |
+
flex-direction: column;
|
| 7 |
+
height: 100vh;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
#controls {
|
| 11 |
+
display: flex;
|
| 12 |
+
padding: 10px;
|
| 13 |
+
background-color: #f0f0f0;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
#search-bar {
|
| 17 |
+
flex: 1;
|
| 18 |
+
padding: 5px;
|
| 19 |
+
font-size: 16px;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
#search-button {
|
| 23 |
+
padding: 5px 10px;
|
| 24 |
+
font-size: 16px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
#webview {
|
| 28 |
+
flex: 1;
|
| 29 |
+
}
|
tokenization_deepseek_fast.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, Optional, Union
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
from transformers.models.llama import LlamaTokenizerFast
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class DeepseekTokenizerFast(LlamaTokenizerFast):
|
| 8 |
+
|
| 9 |
+
def convert_ids_to_tokens(
|
| 10 |
+
self, ids: Union[int, List[int]], skip_special_tokens: bool = False
|
| 11 |
+
) -> Union[str, List[str]]:
|
| 12 |
+
"""
|
| 13 |
+
Converts a single index or a sequence of indices in a token or a sequence of tokens, using the vocabulary and
|
| 14 |
+
added tokens.
|
| 15 |
+
|
| 16 |
+
Args:
|
| 17 |
+
ids (`int` or `List[int]`):
|
| 18 |
+
The token id (or token ids) to convert to tokens.
|
| 19 |
+
skip_special_tokens (`bool`, *optional*, defaults to `False`):
|
| 20 |
+
Whether or not to remove special tokens in the decoding.
|
| 21 |
+
|
| 22 |
+
Returns:
|
| 23 |
+
`str` or `List[str]`: The decoded token(s).
|
| 24 |
+
"""
|
| 25 |
+
if isinstance(ids, int):
|
| 26 |
+
return self._convert_id_to_token(ids)
|
| 27 |
+
tokens = []
|
| 28 |
+
for index in ids:
|
| 29 |
+
index = int(index)
|
| 30 |
+
if skip_special_tokens and index in self.all_special_ids:
|
| 31 |
+
continue
|
| 32 |
+
token = self._tokenizer.id_to_token(index)
|
| 33 |
+
tokens.append(token if token is not None else "")
|
| 34 |
+
return tokens
|
| 35 |
+
|
| 36 |
+
def _convert_id_to_token(self, index: int) -> Optional[str]:
|
| 37 |
+
token = self._tokenizer.id_to_token(int(index))
|
| 38 |
+
return token if token is not None else ""
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"add_prefix_space": null,
|
| 5 |
+
"added_tokens_decoder": {
|
| 6 |
+
"100000": {
|
| 7 |
+
"content": "<|begin▁of▁sentence|>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": true,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false,
|
| 12 |
+
"special": true
|
| 13 |
+
},
|
| 14 |
+
"100001": {
|
| 15 |
+
"content": "<|end▁of▁sentence|>",
|
| 16 |
+
"lstrip": false,
|
| 17 |
+
"normalized": true,
|
| 18 |
+
"rstrip": false,
|
| 19 |
+
"single_word": false,
|
| 20 |
+
"special": true
|
| 21 |
+
},
|
| 22 |
+
"100002": {
|
| 23 |
+
"content": "<|fim▁hole|>",
|
| 24 |
+
"lstrip": false,
|
| 25 |
+
"normalized": true,
|
| 26 |
+
"rstrip": false,
|
| 27 |
+
"single_word": false,
|
| 28 |
+
"special": false
|
| 29 |
+
},
|
| 30 |
+
"100003": {
|
| 31 |
+
"content": "<|fim▁begin|>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": true,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false,
|
| 36 |
+
"special": false
|
| 37 |
+
},
|
| 38 |
+
"100004": {
|
| 39 |
+
"content": "<|fim▁end|>",
|
| 40 |
+
"lstrip": false,
|
| 41 |
+
"normalized": true,
|
| 42 |
+
"rstrip": false,
|
| 43 |
+
"single_word": false,
|
| 44 |
+
"special": false
|
| 45 |
+
},
|
| 46 |
+
"100005": {
|
| 47 |
+
"content": "<|completion|>",
|
| 48 |
+
"lstrip": false,
|
| 49 |
+
"normalized": true,
|
| 50 |
+
"rstrip": false,
|
| 51 |
+
"single_word": false,
|
| 52 |
+
"special": false
|
| 53 |
+
},
|
| 54 |
+
"100006": {
|
| 55 |
+
"content": "<|User|>",
|
| 56 |
+
"lstrip": false,
|
| 57 |
+
"normalized": true,
|
| 58 |
+
"rstrip": false,
|
| 59 |
+
"single_word": false,
|
| 60 |
+
"special": false
|
| 61 |
+
},
|
| 62 |
+
"100007": {
|
| 63 |
+
"content": "<|Assistant|>",
|
| 64 |
+
"lstrip": false,
|
| 65 |
+
"normalized": true,
|
| 66 |
+
"rstrip": false,
|
| 67 |
+
"single_word": false,
|
| 68 |
+
"special": false
|
| 69 |
+
},
|
| 70 |
+
"100008": {
|
| 71 |
+
"content": "<|EOT|>",
|
| 72 |
+
"lstrip": false,
|
| 73 |
+
"normalized": true,
|
| 74 |
+
"rstrip": false,
|
| 75 |
+
"single_word": false,
|
| 76 |
+
"special": true
|
| 77 |
+
},
|
| 78 |
+
"100009": {
|
| 79 |
+
"content": "<|tool▁calls▁begin|>",
|
| 80 |
+
"lstrip": false,
|
| 81 |
+
"normalized": true,
|
| 82 |
+
"rstrip": false,
|
| 83 |
+
"single_word": false,
|
| 84 |
+
"special": false
|
| 85 |
+
},
|
| 86 |
+
"100010": {
|
| 87 |
+
"content": "<|tool▁calls▁end|>",
|
| 88 |
+
"lstrip": false,
|
| 89 |
+
"normalized": true,
|
| 90 |
+
"rstrip": false,
|
| 91 |
+
"single_word": false,
|
| 92 |
+
"special": false
|
| 93 |
+
},
|
| 94 |
+
"100011": {
|
| 95 |
+
"content": "<|tool▁call▁begin|>",
|
| 96 |
+
"lstrip": false,
|
| 97 |
+
"normalized": true,
|
| 98 |
+
"rstrip": false,
|
| 99 |
+
"single_word": false,
|
| 100 |
+
"special": false
|
| 101 |
+
},
|
| 102 |
+
"100012": {
|
| 103 |
+
"content": "<|tool▁call▁end|>",
|
| 104 |
+
"lstrip": false,
|
| 105 |
+
"normalized": true,
|
| 106 |
+
"rstrip": false,
|
| 107 |
+
"single_word": false,
|
| 108 |
+
"special": false
|
| 109 |
+
},
|
| 110 |
+
"100013": {
|
| 111 |
+
"content": "<|tool▁outputs▁begin|>",
|
| 112 |
+
"lstrip": false,
|
| 113 |
+
"normalized": true,
|
| 114 |
+
"rstrip": false,
|
| 115 |
+
"single_word": false,
|
| 116 |
+
"special": false
|
| 117 |
+
},
|
| 118 |
+
"100014": {
|
| 119 |
+
"content": "<|tool▁outputs▁end|>",
|
| 120 |
+
"lstrip": false,
|
| 121 |
+
"normalized": true,
|
| 122 |
+
"rstrip": false,
|
| 123 |
+
"single_word": false,
|
| 124 |
+
"special": false
|
| 125 |
+
},
|
| 126 |
+
"100015": {
|
| 127 |
+
"content": "<|tool▁output▁begin|>",
|
| 128 |
+
"lstrip": false,
|
| 129 |
+
"normalized": true,
|
| 130 |
+
"rstrip": false,
|
| 131 |
+
"single_word": false,
|
| 132 |
+
"special": false
|
| 133 |
+
},
|
| 134 |
+
"100016": {
|
| 135 |
+
"content": "<|tool▁output▁end|>",
|
| 136 |
+
"lstrip": false,
|
| 137 |
+
"normalized": true,
|
| 138 |
+
"rstrip": false,
|
| 139 |
+
"single_word": false,
|
| 140 |
+
"special": false
|
| 141 |
+
},
|
| 142 |
+
"100017": {
|
| 143 |
+
"content": "<|tool▁sep|>",
|
| 144 |
+
"lstrip": false,
|
| 145 |
+
"normalized": true,
|
| 146 |
+
"rstrip": false,
|
| 147 |
+
"single_word": false,
|
| 148 |
+
"special": false
|
| 149 |
+
}
|
| 150 |
+
},
|
| 151 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
| 152 |
+
"clean_up_tokenization_spaces": false,
|
| 153 |
+
"eos_token": "<|end▁of▁sentence|>",
|
| 154 |
+
"extra_special_tokens": {},
|
| 155 |
+
"legacy": true,
|
| 156 |
+
"model_max_length": 16384,
|
| 157 |
+
"pad_token": "<|end▁of▁sentence|>",
|
| 158 |
+
"sp_model_kwargs": {},
|
| 159 |
+
"tokenizer_class": "LlamaTokenizerFast",
|
| 160 |
+
"unk_token": null,
|
| 161 |
+
"use_default_system_prompt": false
|
| 162 |
+
}
|