| --- |
| license: apache-2.0 |
| library_name: transformers |
| pipeline_tag: text-generation |
| tags: |
| - babelbit |
| - bittensor |
| - utterance-prediction |
| --- |
| |
| # Babelbit Miner Model |
|
|
| A fine-tuned utterance prediction model for the Babelbit subnet (netuid 59) on the Bittensor network. |
|
|
| --- |
|
|
| ## What this model does |
|
|
| Given a partial utterance prefix and optional conversation context, the model predicts the most natural and complete continuation of the utterance. |
|
|
| The subnet evaluates predictions on: |
| - **Lexical similarity** — exact word overlap with the ground truth |
| - **Semantic similarity** — meaning-level match |
| - **Earliness** — how early in the utterance the prediction was correct |
|
|
| --- |
|
|
| ## Usage |
|
|
| ### Direct inference |
|
|
| ```python |
| from transformers import AutoModelForCausalLM, AutoTokenizer |
| import torch |
| |
| tokenizer = AutoTokenizer.from_pretrained(model_id) |
| model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.float16) |
| |
| system = ( |
| "You are a helpful assistant that completes the current utterance naturally and succinctly. " |
| "Return only the completed utterance text without quotes or extra commentary." |
| ) |
| prefix = "Hi - how" |
| context = "" |
| |
| if context: |
| user = f"Context:\n{context}\n\nContinue the utterance that begins with:\n{prefix}" |
| else: |
| user = f"Continue the utterance that begins with:\n{prefix}" |
| |
| messages = [ |
| {"role": "system", "content": system}, |
| {"role": "user", "content": user}, |
| ] |
| |
| prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) |
| |
| with torch.inference_mode(): |
| output = model.generate(**inputs, max_new_tokens=64, do_sample=False) |
| |
| decoded = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True) |
| print(decoded) |
| # → "Hi - how are you?" |
| ``` |
|
|
| ### Validator API request format |
|
|
| Validators query the miner at `POST /predict`: |
|
|
| ```json |
| { |
| "index": "<session-uuid>", |
| "step": 3, |
| "prefix": "Hi - how", |
| "context": "", |
| "done": false |
| } |
| ``` |
|
|
| Expected response: |
|
|
| ```json |
| { |
| "prediction": "Hi - how are you?" |
| } |
| ``` |
|
|
| --- |
|
|
| ## Limitations |
|
|
| - Designed specifically for the Babelbit subnet utterance prediction task. |
| - Best results on conversational English; performance varies on other languages. |
| - Predictions are evaluated on partial prefixes — shorter prefixes are inherently harder. |
|
|