Instructions to use TechxGenus/bitnet_b1_58-3B-Coder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TechxGenus/bitnet_b1_58-3B-Coder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TechxGenus/bitnet_b1_58-3B-Coder")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TechxGenus/bitnet_b1_58-3B-Coder") model = AutoModelForCausalLM.from_pretrained("TechxGenus/bitnet_b1_58-3B-Coder") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use TechxGenus/bitnet_b1_58-3B-Coder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TechxGenus/bitnet_b1_58-3B-Coder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TechxGenus/bitnet_b1_58-3B-Coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TechxGenus/bitnet_b1_58-3B-Coder
- SGLang
How to use TechxGenus/bitnet_b1_58-3B-Coder 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 "TechxGenus/bitnet_b1_58-3B-Coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TechxGenus/bitnet_b1_58-3B-Coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "TechxGenus/bitnet_b1_58-3B-Coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TechxGenus/bitnet_b1_58-3B-Coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TechxGenus/bitnet_b1_58-3B-Coder with Docker Model Runner:
docker model run hf.co/TechxGenus/bitnet_b1_58-3B-Coder
Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
### bitnet_b1_58-3B-Coder
|
| 6 |
+
|
| 7 |
+
Code finetuned version of [bitnet_b1_58-3B](https://huggingface.co/1bitLLM/bitnet_b1_58-3B)
|
| 8 |
+
|
| 9 |
+
### Usage
|
| 10 |
+
|
| 11 |
+
```python
|
| 12 |
+
from tokenization_bitnet import BitnetTokenizer
|
| 13 |
+
from transformers import AutoModelForCausalLM
|
| 14 |
+
import torch
|
| 15 |
+
PROMPT = """### Instruction
|
| 16 |
+
{instruction}
|
| 17 |
+
### Response
|
| 18 |
+
"""
|
| 19 |
+
instruction = <Your code instruction here>
|
| 20 |
+
prompt = PROMPT.format(instruction=instruction)
|
| 21 |
+
tokenizer = BitnetTokenizer.from_pretrained(
|
| 22 |
+
"TechxGenus/bitnet_b1_58-3B-Coder",
|
| 23 |
+
trust_remote_code=True,
|
| 24 |
+
)
|
| 25 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 26 |
+
"TechxGenus/bitnet_b1_58-3B-Coder",
|
| 27 |
+
torch_dtype=torch.float16,
|
| 28 |
+
device_map="auto",
|
| 29 |
+
)
|
| 30 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
| 31 |
+
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=2048)
|
| 32 |
+
print(tokenizer.decode(outputs[0]))
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
### Note
|
| 36 |
+
|
| 37 |
+
Model may sometimes make errors, produce misleading contents, or struggle to manage tasks that are not related to coding. It has undergone very limited testing. Additional safety testing should be performed before any real-world deployments.
|