Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,74 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
-
### fireredchat-turn-detector
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
### Acknowledgment
|
| 10 |
-
Base model: google-bert/bert-base-multilingual-cased (license: "apache-2.0")
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- zh
|
| 5 |
+
- en
|
| 6 |
+
base_model:
|
| 7 |
+
- google-bert/bert-base-multilingual-cased
|
| 8 |
+
tags:
|
| 9 |
+
- agent
|
| 10 |
---
|
|
|
|
| 11 |
|
| 12 |
+
<div align="center">
|
| 13 |
+
<h1>FireRedChat-turn-detector</h1>
|
| 14 |
+
</div>
|
| 15 |
+
|
| 16 |
+
<div align="center">
|
| 17 |
+
<a href="https://fireredteam.github.io/demos/firered_chat/">Demo</a> •
|
| 18 |
+
<a href="https://arxiv.org/pdf/2509.06502">Paper</a> •
|
| 19 |
+
<a href="https://huggingface.co/FireRedTeam">Huggingface</a>
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## Descriptions
|
| 24 |
+
|
| 25 |
+
Compact end-of-turn detection used in FireRedChat. [livekit plugin available here](https://github.com/fireredchat-submodules/livekit-plugins-fireredchat-turn-detector)
|
| 26 |
+
- chinese_best_model_q8.onnx: FireRedChat turn-detector model (Chinese only)
|
| 27 |
+
- multilingual_best_model_q8.onnx: FireRedChat turn-detector model (Chinese and English)
|
| 28 |
+
|
| 29 |
+
## Roadmap
|
| 30 |
+
|
| 31 |
+
- [x] 2025/09
|
| 32 |
+
- [x] Release the onnx checkpoints and livekit plugin.
|
| 33 |
+
|
| 34 |
+
## Usage
|
| 35 |
+
```python
|
| 36 |
+
import numpy as np
|
| 37 |
+
import onnxruntime as ort
|
| 38 |
+
from transformers import AutoTokenizer
|
| 39 |
+
|
| 40 |
+
def softmax(x):
|
| 41 |
+
exp_x = np.exp(x - np.max(x, axis=1, keepdims=True))
|
| 42 |
+
return exp_x / np.sum(exp_x, axis=1, keepdims=True)
|
| 43 |
+
|
| 44 |
+
session = ort.InferenceSession(
|
| 45 |
+
"chinese_best_model_q8.onnx", providers=["CPUExecutionProvider"]
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 49 |
+
"./tokenizer",
|
| 50 |
+
local_files_only=True,
|
| 51 |
+
truncation_side="left"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
text = "这是一句没有标点的文本"
|
| 55 |
+
inputs = tokenizer(
|
| 56 |
+
text,
|
| 57 |
+
truncation=True,
|
| 58 |
+
padding='max_length',
|
| 59 |
+
add_special_tokens=False,
|
| 60 |
+
return_tensors="np",
|
| 61 |
+
max_length=128,
|
| 62 |
+
)
|
| 63 |
+
# Run inference
|
| 64 |
+
outputs = session.run(None,
|
| 65 |
+
{
|
| 66 |
+
"input_ids": inputs["input_ids"].astype("int64"),
|
| 67 |
+
"attention_mask": inputs["attention_mask"].astype("int64")
|
| 68 |
+
})
|
| 69 |
+
eou_probability = softmax(outputs[0]).flatten()[-1]
|
| 70 |
+
print(eou_probability, eou_probability>0.5)
|
| 71 |
+
```
|
| 72 |
|
| 73 |
### Acknowledgment
|
| 74 |
+
- Base model: google-bert/bert-base-multilingual-cased (license: "apache-2.0")
|