v1
Browse files- .gitattributes +1 -0
- README.md +95 -3
- added_tokens.json +3 -0
- chat_template.jinja +47 -0
- config.json +56 -0
- generation_config.json +14 -0
- model.safetensors +3 -0
- special_tokens_map.json +33 -0
- tokenizer.json +3 -0
- tokenizer.model +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: gemma
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gemma
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model:
|
| 6 |
+
- google/gemma-3-270m-it
|
| 7 |
+
library_name: transformers
|
| 8 |
+
datasets:
|
| 9 |
+
- juno-labs/text-voice-activity-detection
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
This is a text-based Voice Activity Detection model that determines if a given speech fragment is complete enough for processing by a smart speaker assistant. This allows smart speakers to move from using time based pauses (300ms - 1000ms) to detect the end of voice input to using this model to determine if the voice input is complete.
|
| 13 |
+
|
| 14 |
+
Example:
|
| 15 |
+
|
| 16 |
+
- "Hey" -> no
|
| 17 |
+
- "Hey Juno" -> no
|
| 18 |
+
- "Hey Juno can you" -> no
|
| 19 |
+
- "Hey Juno can you set" -> no
|
| 20 |
+
- "Hey Juno can you set the" -> no
|
| 21 |
+
- "Hey Juno can you set the temperature" -> no
|
| 22 |
+
- "Hey Juno can you set the temperature to" -> no
|
| 23 |
+
- "Hey Juno can you set the temperature to 65" -> yes
|
| 24 |
+
|
| 25 |
+
Model prompting requirements:
|
| 26 |
+
|
| 27 |
+
- Required system prompt: `"You are a Voice Activity Detection system. Determine if the given speech fragment is complete enough for processing. Answer with only 'yes' if complete or 'no' if incomplete."`
|
| 28 |
+
- Required user prompt: `"Is this sentence fragment complete for processing: '{fragment}'"`
|
| 29 |
+
|
| 30 |
+
To use with pipeline from transformers:
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from transformers import pipeline
|
| 34 |
+
|
| 35 |
+
pipe = pipeline("text-generation", model="juno-labs/gemma-text-vad")
|
| 36 |
+
|
| 37 |
+
SYSTEM_PROMPT = (
|
| 38 |
+
"You are a Voice Activity Detection system. "
|
| 39 |
+
"Determine if the given speech fragment is complete enough for processing. Answer with only 'yes' if complete or 'no' if incomplete."
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
SENTENCE = "Hey Juno can you set the temperature to"
|
| 43 |
+
|
| 44 |
+
messages = [
|
| 45 |
+
{'content': SYSTEM_PROMPT, 'role': 'system'},
|
| 46 |
+
{'content': f"Is this sentence fragment complete for processing: '{SENTENCE}'", 'role': 'user'}
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
generated = pipe(messages)
|
| 50 |
+
|
| 51 |
+
classification = generated[0]["generated_text"][2]["content"]
|
| 52 |
+
|
| 53 |
+
print(f"Classification: {classification}") # "yes" or "no"
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
To use with transformers:
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
import torch
|
| 60 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
+
|
| 62 |
+
MODEL_ID = "juno-labs/gemma-text-vad"
|
| 63 |
+
|
| 64 |
+
# Load model + tokenizer
|
| 65 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, device_map="auto")
|
| 66 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 67 |
+
|
| 68 |
+
SYSTEM_PROMPT = (
|
| 69 |
+
"You are a Voice Activity Detection system. "
|
| 70 |
+
"Determine if the given speech fragment is complete enough for processing. Answer with only 'yes' if complete or 'no' if incomplete."
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
SENTENCE = "Set the temperature to 68"
|
| 74 |
+
|
| 75 |
+
messages = [
|
| 76 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 77 |
+
{"role": "user", "content": f"Is this sentence fragment complete for processing: '{SENTENCE}'"},
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 81 |
+
|
| 82 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 83 |
+
|
| 84 |
+
with torch.no_grad():
|
| 85 |
+
outputs = model.generate(
|
| 86 |
+
**inputs,
|
| 87 |
+
max_new_tokens=1, # only 1 token
|
| 88 |
+
do_sample=False, # greedy decoding
|
| 89 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
decoded = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
|
| 93 |
+
|
| 94 |
+
print(f"Classification: {decoded}") # "yes" or "no"
|
| 95 |
+
```
|
added_tokens.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"<image_soft_token>": 262144
|
| 3 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{ bos_token }}
|
| 2 |
+
{%- if messages[0]['role'] == 'system' -%}
|
| 3 |
+
{%- if messages[0]['content'] is string -%}
|
| 4 |
+
{%- set first_user_prefix = messages[0]['content'] + '
|
| 5 |
+
|
| 6 |
+
' -%}
|
| 7 |
+
{%- else -%}
|
| 8 |
+
{%- set first_user_prefix = messages[0]['content'][0]['text'] + '
|
| 9 |
+
|
| 10 |
+
' -%}
|
| 11 |
+
{%- endif -%}
|
| 12 |
+
{%- set loop_messages = messages[1:] -%}
|
| 13 |
+
{%- else -%}
|
| 14 |
+
{%- set first_user_prefix = "" -%}
|
| 15 |
+
{%- set loop_messages = messages -%}
|
| 16 |
+
{%- endif -%}
|
| 17 |
+
{%- for message in loop_messages -%}
|
| 18 |
+
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
|
| 19 |
+
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
|
| 20 |
+
{%- endif -%}
|
| 21 |
+
{%- if (message['role'] == 'assistant') -%}
|
| 22 |
+
{%- set role = "model" -%}
|
| 23 |
+
{%- else -%}
|
| 24 |
+
{%- set role = message['role'] -%}
|
| 25 |
+
{%- endif -%}
|
| 26 |
+
{{ '<start_of_turn>' + role + '
|
| 27 |
+
' + (first_user_prefix if loop.first else "") }}
|
| 28 |
+
{%- if message['content'] is string -%}
|
| 29 |
+
{{ message['content'] | trim }}
|
| 30 |
+
{%- elif message['content'] is iterable -%}
|
| 31 |
+
{%- for item in message['content'] -%}
|
| 32 |
+
{%- if item['type'] == 'image' -%}
|
| 33 |
+
{{ '<start_of_image>' }}
|
| 34 |
+
{%- elif item['type'] == 'text' -%}
|
| 35 |
+
{{ item['text'] | trim }}
|
| 36 |
+
{%- endif -%}
|
| 37 |
+
{%- endfor -%}
|
| 38 |
+
{%- else -%}
|
| 39 |
+
{{ raise_exception("Invalid content type") }}
|
| 40 |
+
{%- endif -%}
|
| 41 |
+
{{ '<end_of_turn>
|
| 42 |
+
' }}
|
| 43 |
+
{%- endfor -%}
|
| 44 |
+
{%- if add_generation_prompt -%}
|
| 45 |
+
{{ '<start_of_turn>model
|
| 46 |
+
' }}
|
| 47 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_sliding_window_pattern": 6,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"Gemma3ForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attn_logit_softcapping": null,
|
| 9 |
+
"bos_token_id": 2,
|
| 10 |
+
"eos_token_id": 106,
|
| 11 |
+
"final_logit_softcapping": null,
|
| 12 |
+
"head_dim": 256,
|
| 13 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 14 |
+
"hidden_size": 640,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 2048,
|
| 17 |
+
"layer_types": [
|
| 18 |
+
"sliding_attention",
|
| 19 |
+
"sliding_attention",
|
| 20 |
+
"sliding_attention",
|
| 21 |
+
"sliding_attention",
|
| 22 |
+
"sliding_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"sliding_attention",
|
| 25 |
+
"sliding_attention",
|
| 26 |
+
"sliding_attention",
|
| 27 |
+
"sliding_attention",
|
| 28 |
+
"sliding_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"sliding_attention",
|
| 31 |
+
"sliding_attention",
|
| 32 |
+
"sliding_attention",
|
| 33 |
+
"sliding_attention",
|
| 34 |
+
"sliding_attention",
|
| 35 |
+
"full_attention"
|
| 36 |
+
],
|
| 37 |
+
"max_position_embeddings": 32768,
|
| 38 |
+
"model_type": "gemma3_text",
|
| 39 |
+
"num_attention_heads": 4,
|
| 40 |
+
"num_hidden_layers": 18,
|
| 41 |
+
"num_key_value_heads": 1,
|
| 42 |
+
"pad_token_id": 0,
|
| 43 |
+
"query_pre_attn_scalar": 256,
|
| 44 |
+
"rms_norm_eps": 1e-06,
|
| 45 |
+
"rope_local_base_freq": 10000.0,
|
| 46 |
+
"rope_scaling": null,
|
| 47 |
+
"rope_theta": 1000000.0,
|
| 48 |
+
"sliding_window": 512,
|
| 49 |
+
"torch_dtype": "bfloat16",
|
| 50 |
+
"transformers_version": "4.55.4",
|
| 51 |
+
"unsloth_fixed": true,
|
| 52 |
+
"unsloth_version": "2025.9.7",
|
| 53 |
+
"use_bidirectional_attention": false,
|
| 54 |
+
"use_cache": true,
|
| 55 |
+
"vocab_size": 262144
|
| 56 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 2,
|
| 3 |
+
"cache_implementation": "hybrid",
|
| 4 |
+
"do_sample": true,
|
| 5 |
+
"eos_token_id": [
|
| 6 |
+
1,
|
| 7 |
+
106
|
| 8 |
+
],
|
| 9 |
+
"max_length": 32768,
|
| 10 |
+
"pad_token_id": 0,
|
| 11 |
+
"top_k": 64,
|
| 12 |
+
"top_p": 0.95,
|
| 13 |
+
"transformers_version": "4.55.4"
|
| 14 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:282aa9a1b21353fa4595e1e1b958a223c199441c08f7068844e32afff0ea4047
|
| 3 |
+
size 536223056
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"boi_token": "<start_of_image>",
|
| 3 |
+
"bos_token": {
|
| 4 |
+
"content": "<bos>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false
|
| 9 |
+
},
|
| 10 |
+
"eoi_token": "<end_of_image>",
|
| 11 |
+
"eos_token": {
|
| 12 |
+
"content": "<end_of_turn>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false
|
| 17 |
+
},
|
| 18 |
+
"image_token": "<image_soft_token>",
|
| 19 |
+
"pad_token": {
|
| 20 |
+
"content": "<pad>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false
|
| 25 |
+
},
|
| 26 |
+
"unk_token": {
|
| 27 |
+
"content": "<unk>",
|
| 28 |
+
"lstrip": false,
|
| 29 |
+
"normalized": false,
|
| 30 |
+
"rstrip": false,
|
| 31 |
+
"single_word": false
|
| 32 |
+
}
|
| 33 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
|
| 3 |
+
size 33384568
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
|
| 3 |
+
size 4689074
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|