cmc2 zrj619 commited on
Commit
00bda64
·
0 Parent(s):

Duplicate from TEN-framework/TEN_Turn_Detection

Browse files

Co-authored-by: zhaorenjie <zrj619@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
+ *.json filter=lfs diff=lfs merge=lfs -text
37
+ *.txt filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ tags:
4
+ - turn detection
5
+ - conversational
6
+ - natural language understanding
7
+ license: apache-2.0
8
+ ---
9
+ # **TEN Turn Detection**
10
+
11
+ ***Turn detection for full-duplex dialogue communication***
12
+
13
+
14
+ ## Introduction
15
+
16
+ **TEN Turn Detection** is an advanced intelligent turn detection model designed specifically for natural and dynamic communication between humans and AI agents. This technology addresses one of the most challenging aspects of human-AI conversation: detecting natural turn-taking cues and enabling contextually-aware interruptions. TEN incorporates deep semantic understanding of conversation context and linguistic patterns to create more natural dialogue with AI.
17
+ <div align="center">
18
+ <img src="images/turn_detection.svg" alt="TEN Turn Detection SVG Diagram" width="800"/>
19
+ </div>
20
+
21
+ **TEN Turn Detection** categorizes user's text into three key states:
22
+
23
+ **finished**: A finished utterance where the user has expressed a complete thought and expects a response. Example: "Hey there I was wondering can you help me with my order"
24
+
25
+ **wait**: An wait utterance where the user has explicitly instructed the AI not to speak. Example: "Shut up"
26
+
27
+ **unfinished**: A clearly unfinished utterance where the user has momentarily paused but intends to continue speaking. Example: "Hello I have a question about"
28
+
29
+ These three classification states allow the TEN system to create natural conversation dynamics by intelligently managing turn-taking, reducing awkward interruptions while maintaining conversation flow.
30
+
31
+ TEN Turn Detection utilizes a multi-layered approach based on the transformer-based language model(Qwen2.5-7B) for semantic analysis.
32
+
33
+ ## Key Features
34
+
35
+ - **Context-Aware Turn Management**
36
+ TEN Turn Detection analyzes linguistic patterns and semantic context to accurately identify turn completion points. This capability enables intelligent interruption handling, allowing the system to determine when interruptions are contextually appropriate while maintaining natural conversation flow across various dialogue scenarios.
37
+
38
+ - **Multilingual Turn Detection Support**
39
+ TEN Turn Detection provides comprehensive support for both English and Chinese languages. It is engineered to accurately identify turn-taking cues and completion signals across multilingual conversations.
40
+
41
+ - **Superior Performance**
42
+ Compared with multiple open-source solutions, TEN achieves superior performance across all metrics on our publicly available test dataset.
43
+
44
+ ## Prepared Dataset
45
+ We have open-sourced the TEN-Turn-Detection TestSet, a bilingual (Chinese and English) collection of conversational inputs specifically designed to evaluate turn detection capabilities in AI dialogue systems. The dataset consists of three distinct components:
46
+
47
+ *wait.txt*: Contains expressions requesting conversation pauses or termination
48
+
49
+ *unfinished.txt*: Features incomplete dialogue inputs with truncated utterances
50
+
51
+ *finished.txt*: Provides complete conversational inputs across multiple domains
52
+
53
+
54
+ ## Detection Performance
55
+
56
+ We conducted comprehensive evaluations comparing several open-source models for turn detection using our test dataset:
57
+
58
+ <div align="center">
59
+
60
+
61
+ | LANGUAGE | MODEL | FINISHED<br>ACCURACY | UNFINISHED<br>ACCURACY | WAIT<br>ACCURACY |
62
+ |:--------:|:-----:|:--------------------:|:----------------------:|:----------------:|
63
+ | English | Model A | 59.74% | 86.46% | N/A |
64
+ | English | Model B | 71.61% | 96.88% | N/A |
65
+ | English | **TEN Turn Detection** | **90.64%** | **98.44%** | **91%** |
66
+
67
+
68
+
69
+
70
+ | LANGUAGE | MODEL | FINISHED<br>ACCURACY | UNFINISHED<br>ACCURACY | WAIT<br>ACCURACY |
71
+ |:--------:|:-----:|:--------------------:|:----------------------:|:----------------:|
72
+ | Chinese | Model B | 74.63% | 88.89% | N/A |
73
+ | Chinese | **TEN Turn Detection** | **98.90%** | **92.74%** | **92%** |
74
+
75
+
76
+ </div>
77
+
78
+ > **Notes:**
79
+ > 1. Model A doesn't support Chinese language processing
80
+ > 2. Neither Model A nor Model B support the "WAIT" state detection
81
+
82
+ ## Quick Start
83
+
84
+ TEN Turn Detection is also available on github [TEN-framework/ten-turn-detection](https://github.com/TEN-framework/ten-turn-detection)
85
+
86
+ ### Installation
87
+
88
+ ```
89
+ pip install "transformers>=4.45.0"
90
+ pip install "torch>=2.0.0"
91
+ ```
92
+
93
+ ### Model Weights
94
+
95
+ The TEN Turn Detection model is available on HuggingFace
96
+
97
+ ### Inference
98
+
99
+ ```python
100
+ from transformers import AutoTokenizer, AutoModelForCausalLM
101
+ import torch
102
+
103
+ # Load model and tokenizer
104
+ model_id = 'TEN-framework/TEN_Turn_Detection'
105
+ model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True, torch_dtype=torch.bfloat16)
106
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
107
+
108
+ # Move model to GPU
109
+ model = model.cuda()
110
+ model.eval()
111
+
112
+ # Function for inference
113
+ def analyze_text(text, system_prompt=""):
114
+ inf_messages = [{"role":"system", "content":system_prompt}] + [{"role":"user", "content":text}]
115
+ input_ids = tokenizer.apply_chat_template(
116
+ inf_messages,
117
+ add_generation_prompt=True,
118
+ return_tensors="pt"
119
+ ).cuda()
120
+
121
+ with torch.no_grad():
122
+ outputs = model.generate(
123
+ input_ids,
124
+ max_new_tokens=1,
125
+ do_sample=True,
126
+ top_p=0.1,
127
+ temperature=0.1,
128
+ pad_token_id=tokenizer.eos_token_id
129
+ )
130
+
131
+ response = outputs[0][input_ids.shape[-1]:]
132
+ return tokenizer.decode(response, skip_special_tokens=True)
133
+
134
+ # Example usage
135
+ text = "Hello I have a question about"
136
+ result = analyze_text(text)
137
+ print(f"Input: '{text}'")
138
+ print(f"Turn Detection Result: '{result}'")
139
+ ```
140
+
141
+ ## Citation
142
+ If you use TEN Turn Detection in your research or applications, please cite:
143
+
144
+ ```
145
+ @misc{TEN_Turn_Detection,
146
+ author = {TEN Team},
147
+ title = {TEN Turn Detection: Turn detection for full-duplex dialogue communication
148
+
149
+ },
150
+ year = {2025},
151
+ url = {https://github.com/TEN-framework/ten-turn-detection},
152
+ }
153
+ ```
154
+ ## License
155
+ This project is Apache 2.0 licensed.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58b54bbe36fc752f79a24a271ef66a0a0830054b4dfad94bde757d851968060b
3
+ size 605
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6aaefde58686ea3e34bcc715f6a5aa6f0d051aeeb6be1dd42941d99c33d2e254
3
+ size 693
generation_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c5df43ff9c1194f0e3a5d81c3f1356d9745b7a7592d281bbc416c6c0ba92922
3
+ size 248
images/turn_detection.svg ADDED
merges.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8831e4f1a044471340f7c0a83d7bd71306a5b867e95fd870f74d0c5308a904d5
3
+ size 1671853
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93f2d70a82c10fb934a32fddfdc2e3e43b563754775329ec8b91d0700eeebc34
3
+ size 4877660776
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bddfa438eb53fbd10a57ce87bb040600168e114ea8639842e0426aaaf3e34c72
3
+ size 4932751008
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20130a8e36107fe3d40f0ad004bdc4ca317cc307fc2fc7f4fbc6add3bd6e0296
3
+ size 4330865200
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b1e8c52badc20cc238b97982a29e9668c2689d9dc97c51778e929e12cc9cdbe
3
+ size 1089994880
model.safetensors.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:998a078123ffc97763690de7f2a677eb89168af5eaf8a5e12e6bc24d18e25bdb
3
+ size 27752
special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76862e765266b85aa9459767e33cbaf13970f327a0e88d1c65846c2ddd3a1ecd
3
+ size 613
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
3
+ size 11421896
tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a5e6a9efdf4606caa92aab4ea9d2b36ce2af1148b00a6db7af33eacfddb98e2
3
+ size 7363
vocab.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910
3
+ size 2776833