Instructions to use JetBrains/CodeLlama-7B-Kexer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JetBrains/CodeLlama-7B-Kexer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="JetBrains/CodeLlama-7B-Kexer")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("JetBrains/CodeLlama-7B-Kexer") model = AutoModelForCausalLM.from_pretrained("JetBrains/CodeLlama-7B-Kexer") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use JetBrains/CodeLlama-7B-Kexer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JetBrains/CodeLlama-7B-Kexer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JetBrains/CodeLlama-7B-Kexer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/JetBrains/CodeLlama-7B-Kexer
- SGLang
How to use JetBrains/CodeLlama-7B-Kexer 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 "JetBrains/CodeLlama-7B-Kexer" \ --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": "JetBrains/CodeLlama-7B-Kexer", "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 "JetBrains/CodeLlama-7B-Kexer" \ --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": "JetBrains/CodeLlama-7B-Kexer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use JetBrains/CodeLlama-7B-Kexer with Docker Model Runner:
docker model run hf.co/JetBrains/CodeLlama-7B-Kexer
Update README.md (#4)
Browse files- Update README.md (76d7a33ae9dedee6a894cd4c6b9731824f151bb4)
Co-authored-by: Anton Shapkin <jdev8@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -10,24 +10,31 @@ This is a repository for fine-tuned CodeLlama-7b model in the Hugging Face Trans
|
|
| 10 |
# Model use
|
| 11 |
|
| 12 |
```python
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
```
|
| 32 |
|
| 33 |
# Training setup
|
|
|
|
| 10 |
# Model use
|
| 11 |
|
| 12 |
```python
|
| 13 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 14 |
+
|
| 15 |
+
# Load pre-trained model and tokenizer
|
| 16 |
+
model_name = 'JetBrains/CodeLlama-7B-Kexer'
|
| 17 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 18 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to('cuda')
|
| 19 |
+
|
| 20 |
+
# Create and encode input
|
| 21 |
+
input_text = """\
|
| 22 |
+
This function takes an integer n and returns factorial of a number:
|
| 23 |
+
fun factorial(n: Int): Int {\
|
| 24 |
+
"""
|
| 25 |
+
input_ids = tokenizer.encode(
|
| 26 |
+
input_text, return_tensors='pt'
|
| 27 |
+
).to('cuda')
|
| 28 |
+
|
| 29 |
+
# Generate
|
| 30 |
+
output = model.generate(
|
| 31 |
+
input_ids, max_length=150, num_return_sequences=1,
|
| 32 |
+
no_repeat_ngram_size=2, early_stopping=True
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Decode output
|
| 36 |
+
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 37 |
+
print(generated_text)
|
| 38 |
```
|
| 39 |
|
| 40 |
# Training setup
|