File size: 1,271 Bytes
757b728
 
 
 
 
 
 
 
f65d1a3
 
 
 
1fa3390
f65d1a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
license: gpl-3.0
datasets:
- agentlans/high-quality-english-sentences
language:
- en
base_model:
- unsloth/Qwen3-0.6B-Base
---

# Qwen3 0.6B Text FIM
This is a model trained to do fill-in-the-middle (FIM) with text.\
This model is used in the [browser-autocomplete](https://github.com/OleFranz/browser-autocomplete) extension.\
It was fine tuned using Unsloth, code [here](https://github.com/OleFranz/qwen3-fim-finetune).

## Example code
```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("OleFranz/Qwen3-0.6B-Text-FIM")
tokenizer = AutoTokenizer.from_pretrained("OleFranz/Qwen3-0.6B-Text-FIM")

prefix = "do you k"
suffix = " the current time?"
prompt = f"<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>"

inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
    **inputs,
    max_new_tokens=64,
    do_sample=True,
    temperature=0.1,
    pad_token_id=tokenizer.eos_token_id
)
middle = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)

GREEN = "\x1b[32m"
RESET = "\x1b[0m"

print(f"Completed text:\n{prefix}{GREEN}{middle}{RESET}{suffix}\n--------------")

raw = tokenizer.decode(outputs[0])

print(f"\nRaw:\n{raw!r}\n---")
```