Abdullahu5mani commited on
Commit
da7c47e
·
verified ·
1 Parent(s): fb947e2

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +187 -0
README.md ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ base_model: Qwen/Qwen2.5-0.5B-Instruct
6
+ tags:
7
+ - text-generation
8
+ - fine-tuned
9
+ - lora
10
+ - gguf
11
+ - speech-to-text
12
+ - text-cleanup
13
+ - unsloth
14
+ - qwen2
15
+ pipeline_tag: text-generation
16
+ datasets:
17
+ - Abdullahu5mani/flowscribe-dataset
18
+ ---
19
+
20
+ # FlowScribe — Qwen2.5-0.5B Speech Transcript Formatter
21
+
22
+ A fine-tuned version of [Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) that converts raw, messy speech-to-text output into clean, formatted text across multiple writing styles.
23
+
24
+ **GitHub:** [github.com/Abdullahu5mani/flowscribe](https://github.com/Abdullahu5mani/flowscribe)
25
+
26
+ ---
27
+
28
+ ## The Problem
29
+
30
+ Voice dictation tools like Whisper produce transcripts full of filler words (`um`, `uh`, `like`), self-corrections (`make it 5... no wait, 6`), and no punctuation or formatting. This model post-processes those transcripts into polished text, with awareness of the desired output style.
31
+
32
+ ---
33
+
34
+ ## Styles
35
+
36
+ | Style | Behavior |
37
+ |---|---|
38
+ | `Auto` | Intelligent default — removes fillers, fixes grammar, handles self-corrections, applies structure |
39
+ | `Professional` | Formal business tone, structured layout, perfect grammar |
40
+ | `Casual` | Keeps the speaker's voice, light cleanup, contractions preserved |
41
+ | `Verbatim` | Preserves exact wording, only strips `um`/`uh` and applies spoken formatting commands |
42
+ | `Software_Dev` | Formats code terms, variable names (`camelCase`, `snake_case`), technical jargon |
43
+ | `Enthusiastic` | High energy, exclamation marks, positive phrasing |
44
+
45
+ ---
46
+
47
+ ## Usage
48
+
49
+ ```python
50
+ from transformers import AutoModelForCausalLM, AutoTokenizer
51
+ import torch
52
+
53
+ model_id = "Abdullahu5mani/flowscribe-qwen2.5-0.5b"
54
+
55
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
56
+ model = AutoModelForCausalLM.from_pretrained(
57
+ model_id,
58
+ torch_dtype=torch.float16,
59
+ device_map="auto"
60
+ )
61
+
62
+ def format_transcript(raw_text, style="Auto"):
63
+ messages = [
64
+ {
65
+ "role": "system",
66
+ "content": "You are a helpful assistant that transcribes and formats text based on a specific style instruction."
67
+ },
68
+ {
69
+ "role": "user",
70
+ "content": f"Transcribe and format this with style: {style}\nInput: {raw_text}"
71
+ }
72
+ ]
73
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
74
+ inputs = tokenizer([text], return_tensors="pt").to(model.device)
75
+ outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
76
+ output_ids = outputs[0][len(inputs.input_ids[0]):]
77
+ return tokenizer.decode(output_ids, skip_special_tokens=True)
78
+
79
+ # Examples
80
+ print(format_transcript(
81
+ "um so the meeting is at 5... no wait make it 6 and uh we need to discuss the q3 budget",
82
+ style="Professional"
83
+ ))
84
+ # → "The meeting is at 6 PM to discuss the Q3 budget."
85
+
86
+ print(format_transcript(
87
+ "the api endpoint is slash api slash users new line it takes a POST request with JSON",
88
+ style="Software_Dev"
89
+ ))
90
+ # → "The API endpoint is `/api/users`\nIt takes a POST request with JSON."
91
+ ```
92
+
93
+ ---
94
+
95
+ ## GGUF (Quantized) Usage
96
+
97
+ A Q4_K_M quantized GGUF version is included in this repository for fast CPU/GPU inference via [llama-cpp-python](https://github.com/abetlen/llama-cpp-python).
98
+
99
+ ```python
100
+ from llama_cpp import Llama
101
+
102
+ llm = Llama(
103
+ model_path="model_q4_k_m.gguf",
104
+ n_ctx=2048,
105
+ n_gpu_layers=-1, # Set to 0 for CPU-only
106
+ verbose=False
107
+ )
108
+
109
+ response = llm.create_chat_completion(
110
+ messages=[
111
+ {
112
+ "role": "system",
113
+ "content": "You are a helpful assistant that transcribes and formats text based on a specific style instruction."
114
+ },
115
+ {
116
+ "role": "user",
117
+ "content": "Transcribe and format this with style: Casual\nInput: hey um so i was thinking we could like grab lunch tomorrow you know around noon ish"
118
+ }
119
+ ],
120
+ max_tokens=256,
121
+ temperature=0.1,
122
+ )
123
+ print(response["choices"][0]["message"]["content"])
124
+ # → "Hey, I was thinking we could grab lunch tomorrow around noon."
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Model Details
130
+
131
+ | Property | Value |
132
+ |---|---|
133
+ | Base model | Qwen/Qwen2.5-0.5B-Instruct |
134
+ | Fine-tuning method | LoRA (via [Unsloth](https://github.com/unslothai/unsloth)) |
135
+ | Parameters | ~500M |
136
+ | Training epochs | 3 |
137
+ | Learning rate | 2e-5 |
138
+ | Effective batch size | 16 (batch 2 × grad accumulation 8) |
139
+ | Sequence length | 2048 |
140
+ | Optimizer | AdamW 8-bit |
141
+ | Training hardware | NVIDIA RTX 3060 8GB VRAM |
142
+ | Chat template | ChatML |
143
+ | Quantization | Q4_K_M (via llama.cpp) |
144
+
145
+ ---
146
+
147
+ ## Training Data
148
+
149
+ Trained on ~19,800 synthetically generated examples from [flowscribe-dataset](https://huggingface.co/datasets/Abdullahu5mani/flowscribe-dataset).
150
+
151
+ Each example is an Alpaca-style JSON object:
152
+ ```json
153
+ {
154
+ "instruction": "Transcribe and format this with style: Professional",
155
+ "input": "um so like the uh proposal is due friday and we need to finalize the, i mean confirm the budget",
156
+ "output": "The proposal is due Friday and we need to confirm the budget."
157
+ }
158
+ ```
159
+
160
+ Data was generated using Google Gemini (primary) and 16 free OpenRouter models (fallback) across 10 domain scenarios: business email, software dev, personal messages, productivity lists, medical notes, and more.
161
+
162
+ ---
163
+
164
+ ## Limitations
165
+
166
+ - Optimized for English only
167
+ - Training data is synthetic — real-world dictation edge cases may vary
168
+ - The 0.5B parameter size prioritizes speed and local deployment over raw capability
169
+ - Dataset reached ~19.8K examples (target was 50K); further training on more data would improve robustness
170
+
171
+ ---
172
+
173
+ ## Files
174
+
175
+ | File | Description |
176
+ |---|---|
177
+ | `model.safetensors` | Full-precision fine-tuned weights |
178
+ | `model_q4_k_m.gguf` | Q4_K_M quantized GGUF for llama.cpp |
179
+ | `config.json` | Model configuration |
180
+ | `tokenizer.json` | Tokenizer |
181
+ | `chat_template.jinja` | ChatML chat template |
182
+
183
+ ---
184
+
185
+ ## License
186
+
187
+ MIT — see [LICENSE](https://github.com/Abdullahu5mani/flowscribe/blob/main/LICENSE)