Instructions to use JetBrains/Mellum-4b-sft-python with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JetBrains/Mellum-4b-sft-python with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="JetBrains/Mellum-4b-sft-python")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("JetBrains/Mellum-4b-sft-python") model = AutoModelForCausalLM.from_pretrained("JetBrains/Mellum-4b-sft-python") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use JetBrains/Mellum-4b-sft-python with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JetBrains/Mellum-4b-sft-python" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JetBrains/Mellum-4b-sft-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/JetBrains/Mellum-4b-sft-python
- SGLang
How to use JetBrains/Mellum-4b-sft-python 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/Mellum-4b-sft-python" \ --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/Mellum-4b-sft-python", "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/Mellum-4b-sft-python" \ --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/Mellum-4b-sft-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use JetBrains/Mellum-4b-sft-python with Docker Model Runner:
docker model run hf.co/JetBrains/Mellum-4b-sft-python
Update README.md
Browse files
README.md
CHANGED
|
@@ -219,18 +219,23 @@ print("### Prediction")
|
|
| 219 |
print(tokenizer.decode(out[0][input_len:]))
|
| 220 |
```
|
| 221 |
|
| 222 |
-
## Fill in the middle generation
|
| 223 |
```python
|
| 224 |
-
|
| 225 |
-
def
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
"""
|
| 232 |
|
| 233 |
-
encoded_input = tokenizer(
|
| 234 |
out = model.generate(
|
| 235 |
**encoded_input,
|
| 236 |
max_new_tokens=100,
|
|
|
|
| 219 |
print(tokenizer.decode(out[0][input_len:]))
|
| 220 |
```
|
| 221 |
|
| 222 |
+
## Fill in the middle with additional files as context generation
|
| 223 |
```python
|
| 224 |
+
example = """<filename>utils.py
|
| 225 |
+
def multiply(x, y):
|
| 226 |
+
return x * y
|
| 227 |
+
<filename>config.py
|
| 228 |
+
DEBUG = True
|
| 229 |
+
MAX_VALUE = 100
|
| 230 |
+
<filename>example.py
|
| 231 |
+
<fim_suffix>
|
| 232 |
|
| 233 |
+
# Test the function
|
| 234 |
+
result = calculate_sum(5, 10)
|
| 235 |
+
print(result)<fim_prefix>def calculate_sum(a, b):
|
| 236 |
+
<fim_middle>"""
|
| 237 |
|
| 238 |
+
encoded_input = tokenizer(example, return_tensors='pt', return_token_type_ids=False)
|
| 239 |
out = model.generate(
|
| 240 |
**encoded_input,
|
| 241 |
max_new_tokens=100,
|