Text Generation
Transformers
Safetensors
English
qwen2
code
text-generation-inference
conversational
Instructions to use Fate-Zero/Archer-Code-1.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Fate-Zero/Archer-Code-1.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Fate-Zero/Archer-Code-1.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Fate-Zero/Archer-Code-1.5B") model = AutoModelForCausalLM.from_pretrained("Fate-Zero/Archer-Code-1.5B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Fate-Zero/Archer-Code-1.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Fate-Zero/Archer-Code-1.5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Fate-Zero/Archer-Code-1.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Fate-Zero/Archer-Code-1.5B
- SGLang
How to use Fate-Zero/Archer-Code-1.5B 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 "Fate-Zero/Archer-Code-1.5B" \ --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": "Fate-Zero/Archer-Code-1.5B", "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 "Fate-Zero/Archer-Code-1.5B" \ --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": "Fate-Zero/Archer-Code-1.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Fate-Zero/Archer-Code-1.5B with Docker Model Runner:
docker model run hf.co/Fate-Zero/Archer-Code-1.5B
Improve model card: Add metadata tags and sample usage
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
|
| 5 |
<div align="center">
|
|
@@ -44,6 +51,47 @@ The Archer series focuses on research into RL algorithms and training for medium
|
|
| 44 |
**Current Models**:
|
| 45 |
- **[Archer-Code-1.5B](https://huggingface.co/Fate-Zero/Archer-Code-1.5B)** - SOTA among similarly-sized models.
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
## Evaluation
|
| 48 |
We conduct evaluation on both mathematical and coding benchmarks. Due to the high variance of the outputs from reasoning models, we report avg@K (pass@1 performance averaged over K outputs) and pass@K for each benchmark. The detailed results are shown in the table below.
|
| 49 |
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
pipeline_tag: text-generation
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- reasoning
|
| 7 |
+
- code-generation
|
| 8 |
+
- math
|
| 9 |
+
- qwen2
|
| 10 |
---
|
| 11 |
|
| 12 |
<div align="center">
|
|
|
|
| 51 |
**Current Models**:
|
| 52 |
- **[Archer-Code-1.5B](https://huggingface.co/Fate-Zero/Archer-Code-1.5B)** - SOTA among similarly-sized models.
|
| 53 |
|
| 54 |
+
## Sample Usage
|
| 55 |
+
|
| 56 |
+
You can use the model with the `transformers` library:
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
import torch
|
| 60 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 61 |
+
|
| 62 |
+
# Load model and tokenizer
|
| 63 |
+
model_id = "Fate-Zero/Archer-Code-1.5B"
|
| 64 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 65 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 66 |
+
model_id,
|
| 67 |
+
torch_dtype=torch.bfloat16, # Use torch.float16 if bfloat16 is not supported on your GPU
|
| 68 |
+
device_map="auto"
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
# Prepare input for code generation
|
| 72 |
+
prompt = "Write a Python function to calculate the nth Fibonacci number."
|
| 73 |
+
messages = [
|
| 74 |
+
{"role": "user", "content": prompt},
|
| 75 |
+
]
|
| 76 |
+
|
| 77 |
+
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 78 |
+
model_inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
|
| 79 |
+
|
| 80 |
+
# Generate response
|
| 81 |
+
generated_ids = model.generate(
|
| 82 |
+
model_inputs.input_ids,
|
| 83 |
+
max_new_tokens=256,
|
| 84 |
+
do_sample=True,
|
| 85 |
+
temperature=0.7,
|
| 86 |
+
top_p=0.9,
|
| 87 |
+
eos_token_id=tokenizer.eos_token_id
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
# Decode and print
|
| 91 |
+
response_text = tokenizer.decode(generated_ids[0][model_inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 92 |
+
print(response_text)
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
## Evaluation
|
| 96 |
We conduct evaluation on both mathematical and coding benchmarks. Due to the high variance of the outputs from reasoning models, we report avg@K (pass@1 performance averaged over K outputs) and pass@K for each benchmark. The detailed results are shown in the table below.
|
| 97 |
|