Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,113 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- bigcode/the-stack
|
5 |
+
- bigcode/the-stack-v2
|
6 |
+
- bigcode/starcoderdata
|
7 |
+
- bigcode/commitpack
|
8 |
+
library_name: transformers
|
9 |
+
tags:
|
10 |
+
- code
|
11 |
+
---
|
12 |
+
|
13 |
+
# Model Description
|
14 |
+
Mellum-4b-sft-python is a fine-tuned version of JetBrains' first open-source large language model (LLM) optimized for code-related tasks.
|
15 |
+
|
16 |
+
Trained on over 4 trillion tokens with a context window of 8192 tokens across multiple programming languages, Mellum-4b-sft-python is tailored specifically for code completion in Python.
|
17 |
+
The model follows a LLaMA-style architecture with 4 billion parameters, making it efficient for both cloud inference (e.g., via vLLM) and local deployment (e.g., using llama.cpp or Ollama).
|
18 |
+
|
19 |
+
Mellum was trained using Automatic Mixed Precision (AMP) with bf16 precision.
|
20 |
+
The uploaded version on Hugging Face retains the bf16 format for public use.
|
21 |
+
|
22 |
+
Designed for integration into professional developer tooling (e.g., intelligent code suggestions in IDEs), AI-powered coding assistants, and research on code understanding and generation, Mellum is also well-suited for educational applications and fine-tuning experiments.
|
23 |
+
|
24 |
+
# Limitations
|
25 |
+
- Biases: May reflect biases present in public codebases. For example it will likely produce code which is similar in style to the open-source repositories.
|
26 |
+
- Security: Code suggestions should not be assumed to be secure or free of vulnerabilities.
|
27 |
+
|
28 |
+
# Sample Usage
|
29 |
+
Here are examples of how to run and sample from the model.
|
30 |
+
|
31 |
+
## Generic generaion
|
32 |
+
```python
|
33 |
+
import json
|
34 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
35 |
+
|
36 |
+
example = """
|
37 |
+
import sys
|
38 |
+
import os
|
39 |
+
import time
|
40 |
+
|
41 |
+
sys.path.append(os.getcwd())
|
42 |
+
|
43 |
+
from cluster.prepare_data import get_headers_pairs_list, write_dist_matrix
|
44 |
+
from cluster.token_edit_distance import get_distance_matrix
|
45 |
+
|
46 |
+
if len(sys.argv) < 3:
|
47 |
+
print(
|
48 |
+
"Too few arguments. You should provide: \n1. dataset_filename" +
|
49 |
+
"\n2. output_data_filename"
|
50 |
+
)
|
51 |
+
sys.exit()
|
52 |
+
|
53 |
+
start = time.perf_counter()
|
54 |
+
dataset_filename_ = sys.argv[1]
|
55 |
+
output_data_filename_ = sys.argv[2]
|
56 |
+
|
57 |
+
headers_pairs = get_headers_pairs_list(dataset_filename_, verbose=True)
|
58 |
+
|
59 |
+
dist_matrix, max_dist = get_distance_matrix(
|
60 |
+
list(map(lambda x: x[1], headers_pairs)),
|
61 |
+
verbose=True
|
62 |
+
)
|
63 |
+
|
64 |
+
write_dist_matrix(dist_matrix, max_dist, output_data_filename_, verbose=True)
|
65 |
+
|
66 |
+
end = time.perf_counter()
|
67 |
+
"""
|
68 |
+
|
69 |
+
tokenizer = AutoTokenizer.from_pretrained('JetBrains/Mellum-4b-base')
|
70 |
+
model = AutoModelForCausalLM.from_pretrained('JetBrains/Mellum-4b-base')
|
71 |
+
encoded_input = tokenizer(example, return_tensors='pt', return_token_type_ids=False)
|
72 |
+
input_len = len(encoded_input["input_ids"][0])
|
73 |
+
out = model.generate(
|
74 |
+
**encoded_input,
|
75 |
+
max_new_tokens=100,
|
76 |
+
)
|
77 |
+
print("### Context")
|
78 |
+
print(tokenizer.decode(out[0][:input_len]))
|
79 |
+
print("### Prediction")
|
80 |
+
print(tokenizer.decode(out[0][input_len:]))
|
81 |
+
```
|
82 |
+
|
83 |
+
## Fill in the middle generation
|
84 |
+
```python
|
85 |
+
prefix = """
|
86 |
+
def fibonacci(n: int) -> int:
|
87 |
+
"""
|
88 |
+
|
89 |
+
suffix = """
|
90 |
+
if __name__ == "__main__":
|
91 |
+
print(fibonacci(10))
|
92 |
+
"""
|
93 |
+
|
94 |
+
encoded_input = tokenizer(f"<fim_suffix>{suffix}<fim_prefix>{prefix}<fim_middle>", return_tensors='pt', return_token_type_ids=False)
|
95 |
+
out = model.generate(
|
96 |
+
**encoded_input,
|
97 |
+
max_new_tokens=100,
|
98 |
+
)
|
99 |
+
```
|
100 |
+
|
101 |
+
# Citation
|
102 |
+
If you use this model, please cite:
|
103 |
+
|
104 |
+
```bibtex
|
105 |
+
@misc{mellum-base-4b,
|
106 |
+
title={Mellum base 4B},
|
107 |
+
author={Nikita Pavlichenko, Iurii Nazarov, Ivan Dolgov, Julia Reshetnikova, Ekaterina Garanina, Karol Lasocki, Sergei Boitsov, Dariia Karaeva, Ivan Bondyrev, Maksim Sheptyakov, Dmitry Ustalov, Nikita Abramov, Olga Kolomyttseva, Kseniia Lysaniuk, Ilia Zavidnyi, Anton Semenkin, Uladzislau Sazanovich},
|
108 |
+
year={2025},
|
109 |
+
}
|
110 |
+
```
|
111 |
+
|
112 |
+
# Contact
|
113 |
+
For questions, collaborations and requests reach us out via [email protected]
|