Text Generation
Transformers
Safetensors
English
recallm_qwen2
recallm
long-context
reasoning
constrained-decoding
information-retrieval
in-context-retrieval
conversational
custom_code
Instructions to use kswhitecross/RecaLLM-Qwen2.5-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kswhitecross/RecaLLM-Qwen2.5-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kswhitecross/RecaLLM-Qwen2.5-7B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("kswhitecross/RecaLLM-Qwen2.5-7B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use kswhitecross/RecaLLM-Qwen2.5-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kswhitecross/RecaLLM-Qwen2.5-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kswhitecross/RecaLLM-Qwen2.5-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kswhitecross/RecaLLM-Qwen2.5-7B
- SGLang
How to use kswhitecross/RecaLLM-Qwen2.5-7B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kswhitecross/RecaLLM-Qwen2.5-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kswhitecross/RecaLLM-Qwen2.5-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kswhitecross/RecaLLM-Qwen2.5-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kswhitecross/RecaLLM-Qwen2.5-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use kswhitecross/RecaLLM-Qwen2.5-7B with Docker Model Runner:
docker model run hf.co/kswhitecross/RecaLLM-Qwen2.5-7B
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +91 -0
- added_tokens.json +28 -0
- chat_template.jinja +54 -0
- config.json +87 -0
- generation_config.json +6 -0
- merges.txt +0 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +347 -0
- modelling_recallm.py +604 -0
- special_tokens_map.json +31 -0
- tokenizer.json +3 -0
- tokenizer_config.json +239 -0
- vocab.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* 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
|
|
|
|
|
|
| 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
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- recallm
|
| 7 |
+
- long-context
|
| 8 |
+
- reasoning
|
| 9 |
+
- constrained-decoding
|
| 10 |
+
- information-retrieval
|
| 11 |
+
- in-context-retrieval
|
| 12 |
+
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 13 |
+
datasets:
|
| 14 |
+
- kswhitecross/RecaLLM-data
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# RecaLLM-Qwen2.5-7B
|
| 19 |
+
|
| 20 |
+
**RecaLLM** is a family of reasoning language models that interleave reasoning with explicit, constrained-decoding **recall spans** that copy evidence verbatim from context. This addresses the **lost-in-thought** phenomenon: reasoning LLMs lose in-context retrieval ability after chain-of-thought generation.
|
| 21 |
+
|
| 22 |
+
This model is RecaLLM trained on **Qwen2.5-7B-Instruct**.
|
| 23 |
+
|
| 24 |
+
**Code:** [https://github.com/kswhitecross/RecaLLM](https://github.com/kswhitecross/RecaLLM)
|
| 25 |
+
|
| 26 |
+
## Quick Start
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 30 |
+
|
| 31 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 32 |
+
"kswhitecross/RecaLLM-Qwen2.5-7B",
|
| 33 |
+
trust_remote_code=True,
|
| 34 |
+
torch_dtype="auto",
|
| 35 |
+
device_map="auto",
|
| 36 |
+
)
|
| 37 |
+
tokenizer = AutoTokenizer.from_pretrained("kswhitecross/RecaLLM-Qwen2.5-7B")
|
| 38 |
+
|
| 39 |
+
messages = [{"role": "user", "content": "Your prompt here..."}]
|
| 40 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
|
| 41 |
+
outputs = model.generate(inputs, max_new_tokens=10240, temperature=0.6, top_p=0.95)
|
| 42 |
+
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=False))
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Recall Spans
|
| 46 |
+
|
| 47 |
+
RecaLLM uses special single tokens `<|start_recall|>` and `<|end_recall|>` to delimit recall spans. During a recall span, a constrained decoding mechanism (built into the model class) masks out invalid tokens at each step, allowing only tokens that continue a valid prefix match against the input context. This guarantees that every recall span is a **verbatim contiguous substring** of the searchable context.
|
| 48 |
+
|
| 49 |
+
The model decides *what* and *when* to recall; constrained decoding ensures the recalled content is exact. Example output:
|
| 50 |
+
|
| 51 |
+
```
|
| 52 |
+
<think>
|
| 53 |
+
I need to find the population of the city mentioned in the document.
|
| 54 |
+
Looking at the context, I see <|start_recall|>The city of Springfield has a population of 167,376<|end_recall|>.
|
| 55 |
+
So the population is 167,376.
|
| 56 |
+
</think>
|
| 57 |
+
|
| 58 |
+
Answer: 167,376
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## System Prompt
|
| 62 |
+
|
| 63 |
+
This model was trained with a specific system prompt that instructs it to use recall spans. The chat template automatically includes this prompt when no system message is provided. **Using a different system prompt may significantly degrade performance.** See the [code repository](https://github.com/kswhitecross/RecaLLM) for the full system prompt.
|
| 64 |
+
|
| 65 |
+
## Inference with vLLM
|
| 66 |
+
|
| 67 |
+
For vLLM inference, use the `VLLMTokenRecaLLMLogitsProcessor` from the [RecaLLM code repository](https://github.com/kswhitecross/RecaLLM). vLLM should load the model using the **base Qwen2 architecture** (not the custom RecaLLM transformers classes) via `hf_overrides`, with the logits processor applied as an overlay:
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
from vllm import LLM, SamplingParams
|
| 71 |
+
from recallm import VLLMTokenRecaLLMLogitsProcessor
|
| 72 |
+
|
| 73 |
+
llm = LLM(
|
| 74 |
+
model="kswhitecross/RecaLLM-Qwen2.5-7B",
|
| 75 |
+
trust_remote_code=True,
|
| 76 |
+
logits_processors=[VLLMTokenRecaLLMLogitsProcessor],
|
| 77 |
+
hf_overrides={
|
| 78 |
+
"model_type": "qwen2",
|
| 79 |
+
"architectures": ["Qwen2ForCausalLM"],
|
| 80 |
+
},
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
sampling_params = SamplingParams(temperature=0.6, top_p=0.95, max_tokens=10240)
|
| 84 |
+
outputs = llm.generate(["Your prompt here..."], sampling_params=sampling_params)
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
See `recallm/recallm_vllm.py` in the code repo for the full logits processor implementation.
|
| 88 |
+
|
| 89 |
+
## Citation
|
| 90 |
+
|
| 91 |
+
<!-- TODO: Add citation once paper is on arXiv -->
|
added_tokens.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</think>": 151668,
|
| 3 |
+
"</tool_call>": 151658,
|
| 4 |
+
"<think>": 151667,
|
| 5 |
+
"<tool_call>": 151657,
|
| 6 |
+
"<|box_end|>": 151649,
|
| 7 |
+
"<|box_start|>": 151648,
|
| 8 |
+
"<|end_recall|>": 151666,
|
| 9 |
+
"<|endoftext|>": 151643,
|
| 10 |
+
"<|file_sep|>": 151664,
|
| 11 |
+
"<|fim_middle|>": 151660,
|
| 12 |
+
"<|fim_pad|>": 151662,
|
| 13 |
+
"<|fim_prefix|>": 151659,
|
| 14 |
+
"<|fim_suffix|>": 151661,
|
| 15 |
+
"<|im_end|>": 151645,
|
| 16 |
+
"<|im_start|>": 151644,
|
| 17 |
+
"<|image_pad|>": 151655,
|
| 18 |
+
"<|object_ref_end|>": 151647,
|
| 19 |
+
"<|object_ref_start|>": 151646,
|
| 20 |
+
"<|quad_end|>": 151651,
|
| 21 |
+
"<|quad_start|>": 151650,
|
| 22 |
+
"<|repo_name|>": 151663,
|
| 23 |
+
"<|start_recall|>": 151665,
|
| 24 |
+
"<|video_pad|>": 151656,
|
| 25 |
+
"<|vision_end|>": 151653,
|
| 26 |
+
"<|vision_pad|>": 151654,
|
| 27 |
+
"<|vision_start|>": 151652
|
| 28 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if tools %}
|
| 2 |
+
{{- '<|im_start|>system\n' }}
|
| 3 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 4 |
+
{{- messages[0]['content'] }}
|
| 5 |
+
{%- else %}
|
| 6 |
+
{{- 'You are a careful reasoning assistant, equipped with a recall tool which lets you\nlook back and faithfully copy information from your context.\n\nFor each task:\n- Restate the goal in your own words.\n- Reason step by step, keeping track of assumptions.\n- If you notice a mistake or contradiction, backtrack and fix it.\n- Verify the final result (e.g., re-check arithmetic, test edge cases,\n confirm units/constraints).\n- When it would be helpful, use your recall tool with <|start_recall|> ... <|end_recall|> to\n look back and find relevant information. Be selective — focus on the passages\n most relevant to your answer.\n\nOutput:\n - First, do all your reasoning and thinking inside of <think> ... </think>\n - After thinking, give a brief justification of your answer, then\n - End with a single final line of the form: Answer: (your final answer here).' }}
|
| 7 |
+
{%- endif %}
|
| 8 |
+
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
| 9 |
+
{%- for tool in tools %}
|
| 10 |
+
{{- "\n" }}
|
| 11 |
+
{{- tool | tojson }}
|
| 12 |
+
{%- endfor %}
|
| 13 |
+
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
| 14 |
+
{%- else %}
|
| 15 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 16 |
+
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
| 17 |
+
{%- else %}
|
| 18 |
+
{{- '<|im_start|>system\nYou are a careful reasoning assistant, equipped with a recall tool which lets you\nlook back and faithfully copy information from your context.\n\nFor each task:\n- Restate the goal in your own words.\n- Reason step by step, keeping track of assumptions.\n- If you notice a mistake or contradiction, backtrack and fix it.\n- Verify the final result (e.g., re-check arithmetic, test edge cases,\n confirm units/constraints).\n- When it would be helpful, use your recall tool with <|start_recall|> ... <|end_recall|> to\n look back and find relevant information. Be selective — focus on the passages\n most relevant to your answer.\n\nOutput:\n - First, do all your reasoning and thinking inside of <think> ... </think>\n - After thinking, give a brief justification of your answer, then\n - End with a single final line of the form: Answer: (your final answer here).<|im_end|>\n' }}
|
| 19 |
+
{%- endif %}
|
| 20 |
+
{%- endif %}
|
| 21 |
+
{%- for message in messages %}
|
| 22 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
| 23 |
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
| 24 |
+
{%- elif message.role == "assistant" %}
|
| 25 |
+
{{- '<|im_start|>' + message.role }}
|
| 26 |
+
{%- if message.content %}
|
| 27 |
+
{{- '\n' + message.content }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{%- for tool_call in message.tool_calls %}
|
| 30 |
+
{%- if tool_call.function is defined %}
|
| 31 |
+
{%- set tool_call = tool_call.function %}
|
| 32 |
+
{%- endif %}
|
| 33 |
+
{{- '\n<tool_call>\n{"name": "' }}
|
| 34 |
+
{{- tool_call.name }}
|
| 35 |
+
{{- '", "arguments": ' }}
|
| 36 |
+
{{- tool_call.arguments | tojson }}
|
| 37 |
+
{{- '}\n</tool_call>' }}
|
| 38 |
+
{%- endfor %}
|
| 39 |
+
{{- '<|im_end|>\n' }}
|
| 40 |
+
{%- elif message.role == "tool" %}
|
| 41 |
+
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
| 42 |
+
{{- '<|im_start|>user' }}
|
| 43 |
+
{%- endif %}
|
| 44 |
+
{{- '\n<tool_response>\n' }}
|
| 45 |
+
{{- message.content }}
|
| 46 |
+
{{- '\n</tool_response>' }}
|
| 47 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 48 |
+
{{- '<|im_end|>\n' }}
|
| 49 |
+
{%- endif %}
|
| 50 |
+
{%- endif %}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{%- if add_generation_prompt %}
|
| 53 |
+
{{- '<|im_start|>assistant\n<think>\n' }}
|
| 54 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"RecaLLMQwen2ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "modelling_recallm.RecaLLMQwen2Config",
|
| 8 |
+
"AutoModel": "modelling_recallm.RecaLLMQwen2Model",
|
| 9 |
+
"AutoModelForCausalLM": "modelling_recallm.RecaLLMQwen2ForCausalLM"
|
| 10 |
+
},
|
| 11 |
+
"close_episode_K_min": 16,
|
| 12 |
+
"close_episode_eps": 0.2,
|
| 13 |
+
"close_episode_prob": 0.3,
|
| 14 |
+
"dtype": "bfloat16",
|
| 15 |
+
"enable_exp_episodes": false,
|
| 16 |
+
"eos_token_id": 151645,
|
| 17 |
+
"force_recall": true,
|
| 18 |
+
"hidden_act": "silu",
|
| 19 |
+
"hidden_size": 3584,
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"intermediate_size": 18944,
|
| 22 |
+
"layer_types": [
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"full_attention",
|
| 50 |
+
"full_attention"
|
| 51 |
+
],
|
| 52 |
+
"max_position_embeddings": 32768,
|
| 53 |
+
"max_recall_length": 128,
|
| 54 |
+
"max_window_layers": 28,
|
| 55 |
+
"model_type": "recallm_qwen2",
|
| 56 |
+
"no_episode_prob": 0.4,
|
| 57 |
+
"num_attention_heads": 28,
|
| 58 |
+
"num_hidden_layers": 28,
|
| 59 |
+
"num_key_value_heads": 4,
|
| 60 |
+
"open_episode_K_max": 32,
|
| 61 |
+
"open_episode_eps": 0.6,
|
| 62 |
+
"open_episode_prob": 0.3,
|
| 63 |
+
"pad_token_id": 151643,
|
| 64 |
+
"profile_recall_masking": false,
|
| 65 |
+
"recall_end_str": "</recall>",
|
| 66 |
+
"recall_end_token_id": 151666,
|
| 67 |
+
"recall_start_str": "<recall>",
|
| 68 |
+
"recall_start_token_id": 151665,
|
| 69 |
+
"recall_tag_type": "token_id",
|
| 70 |
+
"record_recall_prob_after_generate": false,
|
| 71 |
+
"rms_norm_eps": 1e-06,
|
| 72 |
+
"rope_scaling": {
|
| 73 |
+
"factor": 4.0,
|
| 74 |
+
"original_max_position_embeddings": 32768,
|
| 75 |
+
"rope_type": "yarn",
|
| 76 |
+
"type": "yarn"
|
| 77 |
+
},
|
| 78 |
+
"rope_theta": 1000000.0,
|
| 79 |
+
"sliding_window": null,
|
| 80 |
+
"tie_word_embeddings": false,
|
| 81 |
+
"transformers_version": "4.57.6",
|
| 82 |
+
"use_cache": true,
|
| 83 |
+
"use_fast_recall": true,
|
| 84 |
+
"use_sliding_window": false,
|
| 85 |
+
"vllm_disable_recall_masking": false,
|
| 86 |
+
"vocab_size": 151669
|
| 87 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 151643,
|
| 4 |
+
"eos_token_id": 151645,
|
| 5 |
+
"transformers_version": "4.57.6"
|
| 6 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9f4af3bca36404999e7084f9219c76c82f6d8a239f112d9d19d17081bed5c96
|
| 3 |
+
size 4999665008
|
model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e4fa11859ea998f992e77230169631f6a768a4bd97ba3bbdae27bd0ffa06e71d
|
| 3 |
+
size 4866690688
|
model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe95fc040ef0a97743e0d28b020988703bb6dc11540b2797c4df9f786c4aed99
|
| 3 |
+
size 4984886976
|
model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a725a7fe1a91a27d3740a54bb8da579ff9da9b2e1c28ef1a2363d35976363fa
|
| 3 |
+
size 374366472
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_parameters": 7612785152,
|
| 4 |
+
"total_size": 15225570304
|
| 5 |
+
},
|
| 6 |
+
"weight_map": {
|
| 7 |
+
"lm_head.weight": "model-00001-of-00004.safetensors",
|
| 8 |
+
"model.embed_tokens.weight": "model-00003-of-00004.safetensors",
|
| 9 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 10 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 11 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 12 |
+
"model.layers.0.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 13 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 14 |
+
"model.layers.0.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 15 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 16 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 17 |
+
"model.layers.0.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 18 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 19 |
+
"model.layers.0.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 20 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 21 |
+
"model.layers.1.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 22 |
+
"model.layers.1.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 23 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 24 |
+
"model.layers.1.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 25 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 26 |
+
"model.layers.1.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 27 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 28 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 29 |
+
"model.layers.1.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 30 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 31 |
+
"model.layers.1.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 32 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 33 |
+
"model.layers.10.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 34 |
+
"model.layers.10.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 35 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 36 |
+
"model.layers.10.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 37 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 38 |
+
"model.layers.10.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 39 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 40 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 41 |
+
"model.layers.10.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 42 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 43 |
+
"model.layers.10.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 44 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 45 |
+
"model.layers.11.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 46 |
+
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 47 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 48 |
+
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 49 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 50 |
+
"model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 51 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 52 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 53 |
+
"model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 54 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 55 |
+
"model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 56 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 57 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 58 |
+
"model.layers.12.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 59 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 60 |
+
"model.layers.12.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 61 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 62 |
+
"model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 63 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 64 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 65 |
+
"model.layers.12.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 66 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 67 |
+
"model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 68 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 69 |
+
"model.layers.13.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 70 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 71 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 72 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 73 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 74 |
+
"model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 75 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 76 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 77 |
+
"model.layers.13.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 78 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 79 |
+
"model.layers.13.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 80 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 81 |
+
"model.layers.14.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 82 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 83 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 84 |
+
"model.layers.14.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 85 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 86 |
+
"model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 87 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 88 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 89 |
+
"model.layers.14.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 90 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 91 |
+
"model.layers.14.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 92 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 93 |
+
"model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 94 |
+
"model.layers.15.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 95 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 96 |
+
"model.layers.15.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 97 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 98 |
+
"model.layers.15.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 99 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 100 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 101 |
+
"model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 102 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 103 |
+
"model.layers.15.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 104 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 105 |
+
"model.layers.16.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 106 |
+
"model.layers.16.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 107 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 108 |
+
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 109 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 110 |
+
"model.layers.16.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 111 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 112 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 113 |
+
"model.layers.16.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 114 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 115 |
+
"model.layers.16.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 116 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 117 |
+
"model.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 118 |
+
"model.layers.17.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 119 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 120 |
+
"model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 121 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 122 |
+
"model.layers.17.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 123 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 124 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 125 |
+
"model.layers.17.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 126 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 127 |
+
"model.layers.17.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 128 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 129 |
+
"model.layers.18.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 130 |
+
"model.layers.18.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 131 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 132 |
+
"model.layers.18.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 133 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 134 |
+
"model.layers.18.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 135 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 136 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 137 |
+
"model.layers.18.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 138 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 139 |
+
"model.layers.18.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
| 140 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 141 |
+
"model.layers.19.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 142 |
+
"model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 143 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 144 |
+
"model.layers.19.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 145 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 146 |
+
"model.layers.19.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 147 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 148 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 149 |
+
"model.layers.19.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 150 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 151 |
+
"model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 152 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 153 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 154 |
+
"model.layers.2.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 155 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 156 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 157 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 158 |
+
"model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 159 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 160 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 161 |
+
"model.layers.2.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 162 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 163 |
+
"model.layers.2.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 164 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 165 |
+
"model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 166 |
+
"model.layers.20.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 167 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 168 |
+
"model.layers.20.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 169 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 170 |
+
"model.layers.20.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 171 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 172 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 173 |
+
"model.layers.20.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 174 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 175 |
+
"model.layers.20.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
| 176 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 177 |
+
"model.layers.21.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 178 |
+
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 179 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 180 |
+
"model.layers.21.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 181 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 182 |
+
"model.layers.21.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 183 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 184 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 185 |
+
"model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 186 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 187 |
+
"model.layers.21.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 188 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 189 |
+
"model.layers.22.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 190 |
+
"model.layers.22.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 191 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 192 |
+
"model.layers.22.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 193 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 194 |
+
"model.layers.22.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 195 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 196 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 197 |
+
"model.layers.22.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 198 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 199 |
+
"model.layers.22.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 200 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 201 |
+
"model.layers.23.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 202 |
+
"model.layers.23.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 203 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 204 |
+
"model.layers.23.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 205 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 206 |
+
"model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 207 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 208 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 209 |
+
"model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 210 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 211 |
+
"model.layers.23.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 212 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 213 |
+
"model.layers.24.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 214 |
+
"model.layers.24.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 215 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 216 |
+
"model.layers.24.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 217 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 218 |
+
"model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 219 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 220 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 221 |
+
"model.layers.24.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 222 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 223 |
+
"model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 224 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 225 |
+
"model.layers.25.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 226 |
+
"model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 227 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 228 |
+
"model.layers.25.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 229 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 230 |
+
"model.layers.25.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 231 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 232 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 233 |
+
"model.layers.25.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 234 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 235 |
+
"model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 236 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 237 |
+
"model.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 238 |
+
"model.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 239 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 240 |
+
"model.layers.26.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 241 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 242 |
+
"model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 243 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 244 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 245 |
+
"model.layers.26.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
| 246 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 247 |
+
"model.layers.26.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 248 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 249 |
+
"model.layers.27.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 250 |
+
"model.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 251 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 252 |
+
"model.layers.27.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 253 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 254 |
+
"model.layers.27.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 255 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 256 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 257 |
+
"model.layers.27.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 258 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 259 |
+
"model.layers.27.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 260 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 261 |
+
"model.layers.3.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 262 |
+
"model.layers.3.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 263 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 264 |
+
"model.layers.3.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 265 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 266 |
+
"model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 267 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 268 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 269 |
+
"model.layers.3.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 270 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 271 |
+
"model.layers.3.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 272 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 273 |
+
"model.layers.4.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 274 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 275 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 276 |
+
"model.layers.4.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 277 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 278 |
+
"model.layers.4.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 279 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 280 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 281 |
+
"model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 282 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 283 |
+
"model.layers.4.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 284 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 285 |
+
"model.layers.5.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 286 |
+
"model.layers.5.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 287 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 288 |
+
"model.layers.5.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 289 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 290 |
+
"model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 291 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 292 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 293 |
+
"model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 294 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 295 |
+
"model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 296 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 297 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 298 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 299 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 300 |
+
"model.layers.6.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 301 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 302 |
+
"model.layers.6.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 303 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 304 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 305 |
+
"model.layers.6.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 306 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 307 |
+
"model.layers.6.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 308 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 309 |
+
"model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 310 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 311 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 312 |
+
"model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 313 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 314 |
+
"model.layers.7.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 315 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 316 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 317 |
+
"model.layers.7.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 318 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 319 |
+
"model.layers.7.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 320 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 321 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 322 |
+
"model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 323 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 324 |
+
"model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 325 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 326 |
+
"model.layers.8.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 327 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 328 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 329 |
+
"model.layers.8.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 330 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 331 |
+
"model.layers.8.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 332 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 333 |
+
"model.layers.9.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 334 |
+
"model.layers.9.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 335 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 336 |
+
"model.layers.9.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 337 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 338 |
+
"model.layers.9.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 339 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 340 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 341 |
+
"model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 342 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 343 |
+
"model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 344 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 345 |
+
"model.norm.weight": "model-00002-of-00004.safetensors"
|
| 346 |
+
}
|
| 347 |
+
}
|
modelling_recallm.py
ADDED
|
@@ -0,0 +1,604 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
RecaLLM model classes and recall masking logic.
|
| 3 |
+
|
| 4 |
+
Provides the RecaLLM mixin that adds constrained-decoding recall spans to
|
| 5 |
+
any causal language model. During a recall span, the model can only generate
|
| 6 |
+
tokens that continue a valid prefix match against the input context.
|
| 7 |
+
|
| 8 |
+
Supports Llama and Qwen2 architectures.
|
| 9 |
+
"""
|
| 10 |
+
from transformers import (
|
| 11 |
+
AutoConfig,
|
| 12 |
+
AutoModelForCausalLM,
|
| 13 |
+
AutoModel,
|
| 14 |
+
AutoTokenizer,
|
| 15 |
+
LlamaConfig,
|
| 16 |
+
LlamaForCausalLM,
|
| 17 |
+
LlamaModel,
|
| 18 |
+
Qwen2Config,
|
| 19 |
+
Qwen2ForCausalLM,
|
| 20 |
+
Qwen2Model,
|
| 21 |
+
)
|
| 22 |
+
from transformers.modeling_outputs import CausalLMOutputWithPast
|
| 23 |
+
import torch
|
| 24 |
+
from typing import Optional, Union
|
| 25 |
+
import contextlib
|
| 26 |
+
import inspect
|
| 27 |
+
import threading
|
| 28 |
+
|
| 29 |
+
# Large finite negative used instead of float('-inf') for recall masking.
|
| 30 |
+
# Using -inf triggers VeRL's isinf() guard in logprobs_from_logits(), which
|
| 31 |
+
# diverts from the fast Flash Attention Triton kernel to a row-by-row Python
|
| 32 |
+
# loop (~60x slower). exp(-1e4) underflows to exactly 0 in bfloat16/float16/float32,
|
| 33 |
+
# so softmax behavior is identical, but isinf() returns False.
|
| 34 |
+
# -1e4 is the largest safe value across all dtypes (float16 max is 65504;
|
| 35 |
+
# -1e5 overflows to -inf in float16).
|
| 36 |
+
RECALL_MASK_VALUE = -1e4
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
from dataclasses import dataclass, field
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
@dataclass
|
| 43 |
+
class RecallSpan:
|
| 44 |
+
"""Tracks a single recall span within a sequence during generation."""
|
| 45 |
+
input_idx_start: int
|
| 46 |
+
input_idx_end: int
|
| 47 |
+
logits_start: int
|
| 48 |
+
logits_end: int
|
| 49 |
+
span_start: int
|
| 50 |
+
span_end: int
|
| 51 |
+
allowed_tokens_list: list = field(default_factory=list)
|
| 52 |
+
|
| 53 |
+
def get_mask(self, vocab_size: int) -> torch.Tensor:
|
| 54 |
+
"""Build a [span_length, vocab_size] bool mask (True = disallowed)."""
|
| 55 |
+
n_positions = len(self.allowed_tokens_list)
|
| 56 |
+
mask = torch.ones(n_positions, vocab_size, dtype=torch.bool)
|
| 57 |
+
for i, allowed in enumerate(self.allowed_tokens_list):
|
| 58 |
+
mask[i, allowed] = False
|
| 59 |
+
return mask
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def get_prefix_continuations(
|
| 63 |
+
context: torch.Tensor,
|
| 64 |
+
prefix: torch.Tensor,
|
| 65 |
+
) -> torch.Tensor:
|
| 66 |
+
"""
|
| 67 |
+
Find all valid next-token continuations of ``prefix`` in ``context``.
|
| 68 |
+
|
| 69 |
+
Parameters
|
| 70 |
+
----------
|
| 71 |
+
context : torch.Tensor
|
| 72 |
+
1-D tensor of token IDs representing the available context.
|
| 73 |
+
prefix : torch.Tensor
|
| 74 |
+
1-D tensor of token IDs representing the current recall span so far.
|
| 75 |
+
|
| 76 |
+
Returns
|
| 77 |
+
-------
|
| 78 |
+
torch.Tensor
|
| 79 |
+
1-D tensor of unique token IDs that could validly continue the prefix.
|
| 80 |
+
"""
|
| 81 |
+
n = len(prefix)
|
| 82 |
+
if n == 0:
|
| 83 |
+
return context.unique()
|
| 84 |
+
if n >= len(context):
|
| 85 |
+
return torch.tensor([], dtype=context.dtype, device=context.device)
|
| 86 |
+
|
| 87 |
+
windows = context.unfold(0, n, 1)
|
| 88 |
+
match_mask = (windows == prefix.unsqueeze(0)).all(dim=1)
|
| 89 |
+
match_indices = match_mask.nonzero(as_tuple=False).squeeze(1)
|
| 90 |
+
continuation_indices = match_indices + n
|
| 91 |
+
valid = continuation_indices < len(context)
|
| 92 |
+
continuation_indices = continuation_indices[valid]
|
| 93 |
+
|
| 94 |
+
if len(continuation_indices) == 0:
|
| 95 |
+
return torch.tensor([], dtype=context.dtype, device=context.device)
|
| 96 |
+
return context[continuation_indices].unique()
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def _get_prefix_continuations_incremental(
|
| 100 |
+
context: torch.Tensor,
|
| 101 |
+
span_tokens: torch.Tensor,
|
| 102 |
+
recall_start_token_id: int,
|
| 103 |
+
recall_end_token_id: int,
|
| 104 |
+
) -> list[torch.Tensor]:
|
| 105 |
+
"""
|
| 106 |
+
Compute valid continuations for every prefix length in a recall span.
|
| 107 |
+
|
| 108 |
+
Returns R+1 tensors (for the empty prefix through the full span), each
|
| 109 |
+
containing the allowed token IDs at that position. The recall start token
|
| 110 |
+
is excluded from continuations and the recall end token is always appended.
|
| 111 |
+
|
| 112 |
+
This is O(C) per span (single pass over context) instead of O(C*R).
|
| 113 |
+
"""
|
| 114 |
+
C = len(context)
|
| 115 |
+
R = len(span_tokens)
|
| 116 |
+
device = context.device
|
| 117 |
+
|
| 118 |
+
end_tok = torch.tensor([recall_end_token_id], device=device)
|
| 119 |
+
|
| 120 |
+
if C == 0:
|
| 121 |
+
return [end_tok] * (R + 1)
|
| 122 |
+
|
| 123 |
+
# Build match matrix: match[r][c] = True iff span_tokens[r] == context[c]
|
| 124 |
+
if R > 0:
|
| 125 |
+
match = (span_tokens.unsqueeze(1) == context.unsqueeze(0))
|
| 126 |
+
else:
|
| 127 |
+
match = torch.empty(0, C, dtype=torch.bool, device=device)
|
| 128 |
+
|
| 129 |
+
# alive[c] tracks which context positions still match the prefix at each step
|
| 130 |
+
alive = torch.ones(C, dtype=torch.bool, device=device)
|
| 131 |
+
results = []
|
| 132 |
+
|
| 133 |
+
# k=0: empty prefix -> any context token is a valid continuation
|
| 134 |
+
conts_0 = context[alive].unique()
|
| 135 |
+
conts_0 = conts_0[conts_0 != recall_start_token_id]
|
| 136 |
+
results.append(torch.cat([conts_0, end_tok]))
|
| 137 |
+
|
| 138 |
+
for k in range(R):
|
| 139 |
+
alive_shifted = torch.zeros(C, dtype=torch.bool, device=device)
|
| 140 |
+
if k == 0:
|
| 141 |
+
alive_shifted[1:] = match[0, :-1]
|
| 142 |
+
else:
|
| 143 |
+
prev_alive = alive
|
| 144 |
+
alive_shifted[1:] = prev_alive[:-1] & match[k, :-1]
|
| 145 |
+
alive = alive_shifted
|
| 146 |
+
|
| 147 |
+
if not alive.any():
|
| 148 |
+
results.append(end_tok)
|
| 149 |
+
else:
|
| 150 |
+
conts = context[alive].unique()
|
| 151 |
+
conts = conts[conts != recall_start_token_id]
|
| 152 |
+
results.append(torch.cat([conts, end_tok]))
|
| 153 |
+
|
| 154 |
+
return results
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class RecaLLMConfigMixin:
|
| 158 |
+
"""
|
| 159 |
+
Configuration mixin for RecaLLM models.
|
| 160 |
+
|
| 161 |
+
Parameters
|
| 162 |
+
----------
|
| 163 |
+
force_recall : bool, default True
|
| 164 |
+
If True, mask out logits for tokens that would produce non-viable
|
| 165 |
+
sequences inside recall spans.
|
| 166 |
+
recall_tag_type : str, default "token_id"
|
| 167 |
+
Must be "token_id" — uses single-token delimiters for recall spans.
|
| 168 |
+
recall_start_token_id : int
|
| 169 |
+
Token ID for the start of a recall span.
|
| 170 |
+
recall_end_token_id : int
|
| 171 |
+
Token ID for the end of a recall span.
|
| 172 |
+
recall_start_str : str, default "<recall>"
|
| 173 |
+
String representation of recall start (for display/prompts).
|
| 174 |
+
recall_end_str : str, default "</recall>"
|
| 175 |
+
String representation of recall end (for display/prompts).
|
| 176 |
+
max_recall_length : int, default 128
|
| 177 |
+
Maximum tokens in a recall span before forcing closure.
|
| 178 |
+
use_fast_recall : bool, default True
|
| 179 |
+
Use the optimized background-thread forward pass.
|
| 180 |
+
"""
|
| 181 |
+
def __init__(
|
| 182 |
+
self,
|
| 183 |
+
force_recall: bool = True,
|
| 184 |
+
recall_tag_type: str = "token_id",
|
| 185 |
+
recall_start_str: Optional[str] = "<recall>",
|
| 186 |
+
recall_end_str: Optional[str] = "</recall>",
|
| 187 |
+
recall_start_token_id: Optional[int] = None,
|
| 188 |
+
recall_end_token_id: Optional[int] = None,
|
| 189 |
+
record_recall_prob_after_generate: bool = False,
|
| 190 |
+
max_recall_length: int = 128,
|
| 191 |
+
use_fast_recall: bool = True,
|
| 192 |
+
**kwargs):
|
| 193 |
+
super().__init__(**kwargs)
|
| 194 |
+
self.force_recall = force_recall
|
| 195 |
+
self.recall_tag_type = recall_tag_type
|
| 196 |
+
self.recall_start_str = recall_start_str
|
| 197 |
+
self.recall_end_str = recall_end_str
|
| 198 |
+
self.recall_start_token_id = recall_start_token_id
|
| 199 |
+
self.recall_end_token_id = recall_end_token_id
|
| 200 |
+
self.record_recall_prob_after_generate = record_recall_prob_after_generate
|
| 201 |
+
self.max_recall_length = max_recall_length
|
| 202 |
+
self.use_fast_recall = use_fast_recall
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class RecaLLMMixin:
|
| 206 |
+
"""
|
| 207 |
+
Mixin that adds RecaLLM recall masking to any causal LM.
|
| 208 |
+
|
| 209 |
+
Overrides ``forward()`` to mask logits at positions inside recall spans,
|
| 210 |
+
allowing only tokens that continue a valid prefix match against the
|
| 211 |
+
input context. Uses background threading + CUDA stream overlap for
|
| 212 |
+
efficient masking during training.
|
| 213 |
+
"""
|
| 214 |
+
def __init__(self, config: RecaLLMConfigMixin, recall_enabled_in_forward_pass: bool = True):
|
| 215 |
+
super().__init__(config)
|
| 216 |
+
self.recall_enabled_in_forward_pass = recall_enabled_in_forward_pass
|
| 217 |
+
|
| 218 |
+
def forward(
|
| 219 |
+
self,
|
| 220 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 221 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 222 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 223 |
+
labels: Optional[torch.LongTensor] = None,
|
| 224 |
+
logits_to_keep: Union[int, torch.LongTensor] = 0,
|
| 225 |
+
recall_enabled: bool | None = None,
|
| 226 |
+
**kwargs
|
| 227 |
+
) -> CausalLMOutputWithPast:
|
| 228 |
+
"""
|
| 229 |
+
Forward pass with optional recall masking.
|
| 230 |
+
|
| 231 |
+
When recall masking is enabled, logits at positions inside recall spans
|
| 232 |
+
are masked so that only valid context continuations are allowed.
|
| 233 |
+
|
| 234 |
+
Parameters
|
| 235 |
+
----------
|
| 236 |
+
recall_enabled : bool or None
|
| 237 |
+
Override for recall masking. None uses ``self.recall_enabled_in_forward_pass``.
|
| 238 |
+
"""
|
| 239 |
+
if recall_enabled is None:
|
| 240 |
+
recall_enabled = self.recall_enabled_in_forward_pass
|
| 241 |
+
|
| 242 |
+
if recall_enabled:
|
| 243 |
+
assert input_ids is not None, \
|
| 244 |
+
"`input_ids` must be provided when recall masking is enabled."
|
| 245 |
+
assert self.config.recall_tag_type == "token_id", \
|
| 246 |
+
"Only recall_tag_type='token_id' is supported."
|
| 247 |
+
return self._fast_recall_forward(
|
| 248 |
+
input_ids=input_ids, attention_mask=attention_mask,
|
| 249 |
+
position_ids=position_ids, labels=labels,
|
| 250 |
+
logits_to_keep=logits_to_keep, **kwargs)
|
| 251 |
+
|
| 252 |
+
return super().forward(
|
| 253 |
+
input_ids=input_ids,
|
| 254 |
+
attention_mask=attention_mask,
|
| 255 |
+
position_ids=position_ids,
|
| 256 |
+
labels=labels,
|
| 257 |
+
logits_to_keep=logits_to_keep,
|
| 258 |
+
**kwargs,
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
@staticmethod
|
| 262 |
+
def _compute_recall_masks(
|
| 263 |
+
input_ids_cpu: torch.Tensor,
|
| 264 |
+
attention_mask_cpu: Optional[torch.Tensor],
|
| 265 |
+
position_ids_cpu: Optional[torch.Tensor],
|
| 266 |
+
sequence_length: int,
|
| 267 |
+
vocab_size: int,
|
| 268 |
+
start_id: int,
|
| 269 |
+
end_id: int,
|
| 270 |
+
eos_ids_list: list[int],
|
| 271 |
+
keep_logit_start: Optional[int],
|
| 272 |
+
logits_to_keep_map: Optional[dict],
|
| 273 |
+
) -> list[tuple[int, int, int, torch.Tensor]]:
|
| 274 |
+
"""
|
| 275 |
+
Compute all recall masks on CPU (runs in a background thread).
|
| 276 |
+
|
| 277 |
+
Detects recall spans via a state machine, computes valid prefix
|
| 278 |
+
continuations for each position, and builds boolean masks.
|
| 279 |
+
|
| 280 |
+
Returns
|
| 281 |
+
-------
|
| 282 |
+
list of (batch_idx, logits_start, logits_end, bool_mask_cpu) tuples.
|
| 283 |
+
"""
|
| 284 |
+
batch_size = input_ids_cpu.shape[0]
|
| 285 |
+
mask_instructions = []
|
| 286 |
+
|
| 287 |
+
for batch_idx in range(batch_size):
|
| 288 |
+
seq_cpu = input_ids_cpu[batch_idx]
|
| 289 |
+
attn_cpu = attention_mask_cpu[batch_idx] if attention_mask_cpu is not None else None
|
| 290 |
+
pos_cpu = position_ids_cpu[batch_idx] if position_ids_cpu is not None else None
|
| 291 |
+
|
| 292 |
+
# Determine sequence bounds
|
| 293 |
+
if attn_cpu is not None:
|
| 294 |
+
nonzero = attn_cpu.nonzero(as_tuple=False).squeeze(1)
|
| 295 |
+
start_idx = nonzero.min().item()
|
| 296 |
+
end_idx = nonzero.max().item() + 1
|
| 297 |
+
else:
|
| 298 |
+
start_idx = 0
|
| 299 |
+
end_idx = sequence_length
|
| 300 |
+
|
| 301 |
+
# Vectorized event detection
|
| 302 |
+
seq_slice = seq_cpu[start_idx:end_idx]
|
| 303 |
+
|
| 304 |
+
is_start = (seq_slice == start_id)
|
| 305 |
+
start_positions = is_start.nonzero(as_tuple=False).squeeze(1) + start_idx
|
| 306 |
+
|
| 307 |
+
is_end = (seq_slice == end_id)
|
| 308 |
+
for eid in eos_ids_list:
|
| 309 |
+
is_end = is_end | (seq_slice == eid)
|
| 310 |
+
end_positions = is_end.nonzero(as_tuple=False).squeeze(1) + start_idx
|
| 311 |
+
|
| 312 |
+
if pos_cpu is not None:
|
| 313 |
+
pos_slice = pos_cpu[start_idx:end_idx]
|
| 314 |
+
is_boundary = torch.zeros(pos_slice.shape[0], dtype=torch.bool)
|
| 315 |
+
if pos_slice.shape[0] > 1:
|
| 316 |
+
is_boundary[1:] = (pos_slice[1:] == 0)
|
| 317 |
+
boundary_positions = is_boundary.nonzero(as_tuple=False).squeeze(1) + start_idx
|
| 318 |
+
else:
|
| 319 |
+
boundary_positions = torch.tensor([], dtype=torch.long)
|
| 320 |
+
|
| 321 |
+
# Build sorted event list
|
| 322 |
+
events = []
|
| 323 |
+
for p in start_positions.tolist():
|
| 324 |
+
events.append((p, 0)) # start recall
|
| 325 |
+
for p in end_positions.tolist():
|
| 326 |
+
events.append((p, 1)) # end recall
|
| 327 |
+
for p in boundary_positions.tolist():
|
| 328 |
+
events.append((p, 2)) # sequence boundary
|
| 329 |
+
events.sort(key=lambda e: (e[0], e[1]))
|
| 330 |
+
|
| 331 |
+
# State machine to extract recall spans
|
| 332 |
+
in_recall_mode = False
|
| 333 |
+
context_start = start_idx
|
| 334 |
+
current_content_start = None
|
| 335 |
+
current_ctx_start = None
|
| 336 |
+
raw_spans = []
|
| 337 |
+
|
| 338 |
+
for pos, etype in events:
|
| 339 |
+
if etype == 0:
|
| 340 |
+
if not in_recall_mode:
|
| 341 |
+
in_recall_mode = True
|
| 342 |
+
current_content_start = pos + 1
|
| 343 |
+
current_ctx_start = context_start
|
| 344 |
+
elif etype == 1:
|
| 345 |
+
if in_recall_mode:
|
| 346 |
+
in_recall_mode = False
|
| 347 |
+
raw_spans.append((current_ctx_start, current_content_start, pos))
|
| 348 |
+
current_content_start = None
|
| 349 |
+
current_ctx_start = None
|
| 350 |
+
|
| 351 |
+
if etype == 2:
|
| 352 |
+
if in_recall_mode:
|
| 353 |
+
raw_spans.append((current_ctx_start, current_content_start, pos))
|
| 354 |
+
in_recall_mode = False
|
| 355 |
+
current_content_start = None
|
| 356 |
+
current_ctx_start = None
|
| 357 |
+
context_start = pos
|
| 358 |
+
|
| 359 |
+
if in_recall_mode:
|
| 360 |
+
raw_spans.append((current_ctx_start, current_content_start, end_idx))
|
| 361 |
+
|
| 362 |
+
# For each span: prefix match + build bool mask
|
| 363 |
+
for (ctx_start, content_start, content_end) in raw_spans:
|
| 364 |
+
if content_end < content_start:
|
| 365 |
+
continue
|
| 366 |
+
|
| 367 |
+
start_token_pos = content_start - 1
|
| 368 |
+
|
| 369 |
+
if keep_logit_start is not None:
|
| 370 |
+
if content_end - 1 < keep_logit_start:
|
| 371 |
+
continue
|
| 372 |
+
elif logits_to_keep_map is not None:
|
| 373 |
+
has_any = False
|
| 374 |
+
for p in range(start_token_pos, content_end):
|
| 375 |
+
if p in logits_to_keep_map:
|
| 376 |
+
has_any = True
|
| 377 |
+
break
|
| 378 |
+
if not has_any:
|
| 379 |
+
continue
|
| 380 |
+
|
| 381 |
+
context = seq_cpu[ctx_start:content_start - 1]
|
| 382 |
+
span_tokens = seq_cpu[content_start:content_end]
|
| 383 |
+
|
| 384 |
+
allowed_lists = _get_prefix_continuations_incremental(
|
| 385 |
+
context=context,
|
| 386 |
+
span_tokens=span_tokens,
|
| 387 |
+
recall_start_token_id=start_id,
|
| 388 |
+
recall_end_token_id=end_id,
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
# Filter to positions that have logits
|
| 392 |
+
mask_positions = list(range(start_token_pos, content_end))
|
| 393 |
+
filtered_allowed = []
|
| 394 |
+
logits_start = None
|
| 395 |
+
logits_end = None
|
| 396 |
+
|
| 397 |
+
for i, abs_pos in enumerate(mask_positions):
|
| 398 |
+
logits_idx = None
|
| 399 |
+
if keep_logit_start is not None:
|
| 400 |
+
if abs_pos >= keep_logit_start:
|
| 401 |
+
logits_idx = abs_pos - keep_logit_start
|
| 402 |
+
elif logits_to_keep_map is not None:
|
| 403 |
+
if abs_pos in logits_to_keep_map:
|
| 404 |
+
logits_idx = logits_to_keep_map[abs_pos]
|
| 405 |
+
|
| 406 |
+
if logits_idx is not None:
|
| 407 |
+
filtered_allowed.append(allowed_lists[i])
|
| 408 |
+
if logits_start is None:
|
| 409 |
+
logits_start = logits_idx
|
| 410 |
+
logits_end = logits_idx + 1
|
| 411 |
+
|
| 412 |
+
# Build boolean mask on CPU
|
| 413 |
+
if logits_start is not None:
|
| 414 |
+
N = len(filtered_allowed)
|
| 415 |
+
bool_mask = torch.ones(N, vocab_size, dtype=torch.bool, pin_memory=True)
|
| 416 |
+
sizes = torch.tensor([a.numel() for a in filtered_allowed])
|
| 417 |
+
row_idx = torch.repeat_interleave(torch.arange(N), sizes)
|
| 418 |
+
col_idx = torch.cat(filtered_allowed)
|
| 419 |
+
bool_mask[row_idx, col_idx] = False
|
| 420 |
+
|
| 421 |
+
mask_instructions.append((batch_idx, logits_start, logits_end, bool_mask))
|
| 422 |
+
|
| 423 |
+
return mask_instructions
|
| 424 |
+
|
| 425 |
+
def _fast_recall_forward(
|
| 426 |
+
self,
|
| 427 |
+
input_ids: torch.LongTensor,
|
| 428 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 429 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 430 |
+
labels: Optional[torch.LongTensor] = None,
|
| 431 |
+
logits_to_keep: Union[int, torch.LongTensor] = 0,
|
| 432 |
+
**kwargs,
|
| 433 |
+
) -> CausalLMOutputWithPast:
|
| 434 |
+
"""
|
| 435 |
+
Optimized forward pass with recall masking (token_id mode only).
|
| 436 |
+
|
| 437 |
+
Overlaps CPU-bound mask computation and GPU mask transfer with the
|
| 438 |
+
model forward pass using a background thread + CUDA stream.
|
| 439 |
+
|
| 440 |
+
Flow:
|
| 441 |
+
1. Copy input_ids / attention_mask / position_ids to CPU
|
| 442 |
+
2. Background thread: span detection + prefix matching + bool mask
|
| 443 |
+
building (CPU), then transfer masks to GPU on a dedicated stream
|
| 444 |
+
3. Run super().forward() on the default CUDA stream (overlaps with 2)
|
| 445 |
+
4. Join thread, sync streams, apply masks to logits
|
| 446 |
+
5. Compute loss if labels provided
|
| 447 |
+
"""
|
| 448 |
+
assert self.config.recall_tag_type == "token_id", \
|
| 449 |
+
"_fast_recall_forward only supports recall_tag_type='token_id'"
|
| 450 |
+
|
| 451 |
+
batch_size = input_ids.shape[0]
|
| 452 |
+
sequence_length = input_ids.shape[1]
|
| 453 |
+
|
| 454 |
+
# --- Step A: Precompute config values ---
|
| 455 |
+
keep_logit_start = None
|
| 456 |
+
if isinstance(logits_to_keep, int):
|
| 457 |
+
keep_logit_start = 0 if logits_to_keep == 0 else sequence_length - logits_to_keep
|
| 458 |
+
|
| 459 |
+
logits_to_keep_map = None
|
| 460 |
+
if isinstance(logits_to_keep, torch.Tensor):
|
| 461 |
+
ltk_cpu = logits_to_keep.cpu()
|
| 462 |
+
logits_to_keep_map = {pos.item(): idx for idx, pos in enumerate(ltk_cpu)}
|
| 463 |
+
|
| 464 |
+
start_id = self.config.recall_start_token_id
|
| 465 |
+
end_id = self.config.recall_end_token_id
|
| 466 |
+
eos_id = self.config.eos_token_id
|
| 467 |
+
if isinstance(eos_id, int):
|
| 468 |
+
eos_ids_list = [eos_id]
|
| 469 |
+
elif isinstance(eos_id, list):
|
| 470 |
+
eos_ids_list = eos_id
|
| 471 |
+
else:
|
| 472 |
+
eos_ids_list = []
|
| 473 |
+
|
| 474 |
+
vocab_size = self.config.vocab_size
|
| 475 |
+
|
| 476 |
+
# --- Step B: Copy inputs to CPU ---
|
| 477 |
+
input_ids_cpu = input_ids.cpu()
|
| 478 |
+
attention_mask_cpu = attention_mask.cpu() if attention_mask is not None else None
|
| 479 |
+
position_ids_cpu = position_ids.cpu() if position_ids is not None else None
|
| 480 |
+
|
| 481 |
+
# --- Step C: Background thread for CPU mask computation + GPU transfer ---
|
| 482 |
+
target_device = input_ids.device
|
| 483 |
+
thread_result = [None]
|
| 484 |
+
thread_stream = [None]
|
| 485 |
+
thread_error = [None]
|
| 486 |
+
|
| 487 |
+
def _mask_thread():
|
| 488 |
+
try:
|
| 489 |
+
masks_cpu = self._compute_recall_masks(
|
| 490 |
+
input_ids_cpu=input_ids_cpu,
|
| 491 |
+
attention_mask_cpu=attention_mask_cpu,
|
| 492 |
+
position_ids_cpu=position_ids_cpu,
|
| 493 |
+
sequence_length=sequence_length,
|
| 494 |
+
vocab_size=vocab_size,
|
| 495 |
+
start_id=start_id,
|
| 496 |
+
end_id=end_id,
|
| 497 |
+
eos_ids_list=eos_ids_list,
|
| 498 |
+
keep_logit_start=keep_logit_start,
|
| 499 |
+
logits_to_keep_map=logits_to_keep_map,
|
| 500 |
+
)
|
| 501 |
+
if masks_cpu and target_device.type == 'cuda':
|
| 502 |
+
stream = torch.cuda.Stream(device=target_device)
|
| 503 |
+
masks_gpu = []
|
| 504 |
+
with torch.cuda.stream(stream):
|
| 505 |
+
for batch_idx, ls, le, bm_cpu in masks_cpu:
|
| 506 |
+
bm_gpu = bm_cpu.to(target_device, non_blocking=True)
|
| 507 |
+
masks_gpu.append((batch_idx, ls, le, bm_gpu))
|
| 508 |
+
thread_result[0] = masks_gpu
|
| 509 |
+
thread_stream[0] = stream
|
| 510 |
+
else:
|
| 511 |
+
thread_result[0] = masks_cpu
|
| 512 |
+
except Exception as e:
|
| 513 |
+
thread_error[0] = e
|
| 514 |
+
|
| 515 |
+
mask_thread = threading.Thread(target=_mask_thread, daemon=True)
|
| 516 |
+
mask_thread.start()
|
| 517 |
+
|
| 518 |
+
# --- Step D: Run base model forward on GPU (overlaps with thread) ---
|
| 519 |
+
outputs = super().forward(
|
| 520 |
+
input_ids=input_ids,
|
| 521 |
+
attention_mask=attention_mask,
|
| 522 |
+
logits_to_keep=logits_to_keep,
|
| 523 |
+
position_ids=position_ids,
|
| 524 |
+
**kwargs,
|
| 525 |
+
)
|
| 526 |
+
|
| 527 |
+
# --- Step E: Wait for background thread ---
|
| 528 |
+
mask_thread.join()
|
| 529 |
+
|
| 530 |
+
if thread_error[0] is not None:
|
| 531 |
+
raise thread_error[0]
|
| 532 |
+
|
| 533 |
+
mask_instructions = thread_result[0]
|
| 534 |
+
logits_device = outputs.logits.device
|
| 535 |
+
|
| 536 |
+
# --- Step F: Apply masks to logits ---
|
| 537 |
+
if thread_stream[0] is not None:
|
| 538 |
+
torch.cuda.current_stream(logits_device).wait_stream(thread_stream[0])
|
| 539 |
+
|
| 540 |
+
for batch_idx, logits_start, logits_end, bool_mask in mask_instructions:
|
| 541 |
+
outputs.logits[batch_idx, logits_start:logits_end, :].masked_fill_(
|
| 542 |
+
bool_mask, RECALL_MASK_VALUE
|
| 543 |
+
)
|
| 544 |
+
|
| 545 |
+
# --- Step G: Compute loss if labels provided ---
|
| 546 |
+
if labels is not None:
|
| 547 |
+
loss_func_params = set(inspect.signature(self.loss_function).parameters.keys())
|
| 548 |
+
loss_func_kwargs = {key: val for key, val in kwargs.items() if key in loss_func_params}
|
| 549 |
+
outputs["loss"] = self.loss_function(
|
| 550 |
+
logits=outputs.logits, labels=labels,
|
| 551 |
+
vocab_size=self.config.vocab_size, **loss_func_kwargs,
|
| 552 |
+
)
|
| 553 |
+
|
| 554 |
+
return outputs
|
| 555 |
+
|
| 556 |
+
def enable_recall_in_forward_pass(self):
|
| 557 |
+
self.recall_enabled_in_forward_pass = True
|
| 558 |
+
|
| 559 |
+
def disable_recall_in_forward_pass(self):
|
| 560 |
+
self.recall_enabled_in_forward_pass = False
|
| 561 |
+
|
| 562 |
+
@contextlib.contextmanager
|
| 563 |
+
def temp_disable_recall_in_forward_pass(self):
|
| 564 |
+
original = self.recall_enabled_in_forward_pass
|
| 565 |
+
self.disable_recall_in_forward_pass()
|
| 566 |
+
try:
|
| 567 |
+
yield
|
| 568 |
+
finally:
|
| 569 |
+
self.recall_enabled_in_forward_pass = original
|
| 570 |
+
|
| 571 |
+
def get_base_model(self):
|
| 572 |
+
return super()
|
| 573 |
+
|
| 574 |
+
|
| 575 |
+
# ── Model Registration ──────────────────────────────────────────────────────
|
| 576 |
+
# Llama 3 RecaLLM models
|
| 577 |
+
class RecaLLMLlamaConfig(RecaLLMConfigMixin, LlamaConfig):
|
| 578 |
+
model_type = "recallm_llama"
|
| 579 |
+
|
| 580 |
+
class RecaLLMLlamaForCausalLM(RecaLLMMixin, LlamaForCausalLM):
|
| 581 |
+
config_class = RecaLLMLlamaConfig
|
| 582 |
+
|
| 583 |
+
class RecaLLMLlamaModel(RecaLLMMixin, LlamaModel):
|
| 584 |
+
config_class = RecaLLMLlamaConfig
|
| 585 |
+
_supports_attention_backend = True
|
| 586 |
+
|
| 587 |
+
AutoConfig.register("recallm_llama", RecaLLMLlamaConfig)
|
| 588 |
+
AutoModelForCausalLM.register(RecaLLMLlamaConfig, RecaLLMLlamaForCausalLM)
|
| 589 |
+
AutoModel.register(RecaLLMLlamaConfig, RecaLLMLlamaModel)
|
| 590 |
+
|
| 591 |
+
# Qwen 2 (and 2.5) RecaLLM models
|
| 592 |
+
class RecaLLMQwen2Config(RecaLLMConfigMixin, Qwen2Config):
|
| 593 |
+
model_type = "recallm_qwen2"
|
| 594 |
+
|
| 595 |
+
class RecaLLMQwen2ForCausalLM(RecaLLMMixin, Qwen2ForCausalLM):
|
| 596 |
+
config_class = RecaLLMQwen2Config
|
| 597 |
+
|
| 598 |
+
class RecaLLMQwen2Model(RecaLLMMixin, Qwen2Model):
|
| 599 |
+
config_class = RecaLLMQwen2Config
|
| 600 |
+
_supports_attention_backend = True
|
| 601 |
+
|
| 602 |
+
AutoConfig.register("recallm_qwen2", RecaLLMQwen2Config)
|
| 603 |
+
AutoModelForCausalLM.register(RecaLLMQwen2Config, RecaLLMQwen2ForCausalLM)
|
| 604 |
+
AutoModel.register(RecaLLMQwen2Config, RecaLLMQwen2Model)
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|im_start|>",
|
| 4 |
+
"<|im_end|>",
|
| 5 |
+
"<|object_ref_start|>",
|
| 6 |
+
"<|object_ref_end|>",
|
| 7 |
+
"<|box_start|>",
|
| 8 |
+
"<|box_end|>",
|
| 9 |
+
"<|quad_start|>",
|
| 10 |
+
"<|quad_end|>",
|
| 11 |
+
"<|vision_start|>",
|
| 12 |
+
"<|vision_end|>",
|
| 13 |
+
"<|vision_pad|>",
|
| 14 |
+
"<|image_pad|>",
|
| 15 |
+
"<|video_pad|>"
|
| 16 |
+
],
|
| 17 |
+
"eos_token": {
|
| 18 |
+
"content": "<|im_end|>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
},
|
| 24 |
+
"pad_token": {
|
| 25 |
+
"content": "<|endoftext|>",
|
| 26 |
+
"lstrip": false,
|
| 27 |
+
"normalized": false,
|
| 28 |
+
"rstrip": false,
|
| 29 |
+
"single_word": false
|
| 30 |
+
}
|
| 31 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1bd65c75b9f0aad032a905964e080ce1964b14fe101883d40fe86c5a39624f6c
|
| 3 |
+
size 11422653
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_prefix_space": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"151643": {
|
| 6 |
+
"content": "<|endoftext|>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"151644": {
|
| 14 |
+
"content": "<|im_start|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"151645": {
|
| 22 |
+
"content": "<|im_end|>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"151646": {
|
| 30 |
+
"content": "<|object_ref_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"151647": {
|
| 38 |
+
"content": "<|object_ref_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"151648": {
|
| 46 |
+
"content": "<|box_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"151649": {
|
| 54 |
+
"content": "<|box_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"151650": {
|
| 62 |
+
"content": "<|quad_start|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"151651": {
|
| 70 |
+
"content": "<|quad_end|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"151652": {
|
| 78 |
+
"content": "<|vision_start|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"151653": {
|
| 86 |
+
"content": "<|vision_end|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"151654": {
|
| 94 |
+
"content": "<|vision_pad|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"151655": {
|
| 102 |
+
"content": "<|image_pad|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"151656": {
|
| 110 |
+
"content": "<|video_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"151657": {
|
| 118 |
+
"content": "<tool_call>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": false
|
| 124 |
+
},
|
| 125 |
+
"151658": {
|
| 126 |
+
"content": "</tool_call>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": false
|
| 132 |
+
},
|
| 133 |
+
"151659": {
|
| 134 |
+
"content": "<|fim_prefix|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": false
|
| 140 |
+
},
|
| 141 |
+
"151660": {
|
| 142 |
+
"content": "<|fim_middle|>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"151661": {
|
| 150 |
+
"content": "<|fim_suffix|>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"151662": {
|
| 158 |
+
"content": "<|fim_pad|>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"151663": {
|
| 166 |
+
"content": "<|repo_name|>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"151664": {
|
| 174 |
+
"content": "<|file_sep|>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"151665": {
|
| 182 |
+
"content": "<|start_recall|>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": false
|
| 188 |
+
},
|
| 189 |
+
"151666": {
|
| 190 |
+
"content": "<|end_recall|>",
|
| 191 |
+
"lstrip": false,
|
| 192 |
+
"normalized": false,
|
| 193 |
+
"rstrip": false,
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"special": false
|
| 196 |
+
},
|
| 197 |
+
"151667": {
|
| 198 |
+
"content": "<think>",
|
| 199 |
+
"lstrip": false,
|
| 200 |
+
"normalized": false,
|
| 201 |
+
"rstrip": false,
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"special": false
|
| 204 |
+
},
|
| 205 |
+
"151668": {
|
| 206 |
+
"content": "</think>",
|
| 207 |
+
"lstrip": false,
|
| 208 |
+
"normalized": false,
|
| 209 |
+
"rstrip": false,
|
| 210 |
+
"single_word": false,
|
| 211 |
+
"special": false
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
"additional_special_tokens": [
|
| 215 |
+
"<|im_start|>",
|
| 216 |
+
"<|im_end|>",
|
| 217 |
+
"<|object_ref_start|>",
|
| 218 |
+
"<|object_ref_end|>",
|
| 219 |
+
"<|box_start|>",
|
| 220 |
+
"<|box_end|>",
|
| 221 |
+
"<|quad_start|>",
|
| 222 |
+
"<|quad_end|>",
|
| 223 |
+
"<|vision_start|>",
|
| 224 |
+
"<|vision_end|>",
|
| 225 |
+
"<|vision_pad|>",
|
| 226 |
+
"<|image_pad|>",
|
| 227 |
+
"<|video_pad|>"
|
| 228 |
+
],
|
| 229 |
+
"bos_token": null,
|
| 230 |
+
"clean_up_tokenization_spaces": false,
|
| 231 |
+
"eos_token": "<|im_end|>",
|
| 232 |
+
"errors": "replace",
|
| 233 |
+
"extra_special_tokens": {},
|
| 234 |
+
"model_max_length": 131072,
|
| 235 |
+
"pad_token": "<|endoftext|>",
|
| 236 |
+
"split_special_tokens": false,
|
| 237 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 238 |
+
"unk_token": null
|
| 239 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|