GanymedeNil shibing624 commited on
Commit
2803eb1
0 Parent(s):

Duplicate from shibing624/text2vec

Browse files

Co-authored-by: xuming <shibing624@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +27 -0
  2. README.md +13 -0
  3. app.py +40 -0
  4. requirements.txt +4 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 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
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Text2vec
3
+ emoji: 🔥
4
+ colorFrom: green
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ app_file: app.py
8
+ pinned: false
9
+ license: apache-2.0
10
+ duplicated_from: shibing624/text2vec
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ @author:XuMing(xuming624@qq.com)
4
+ @description: text similarity example, fine-tuned by CoSENT model
5
+ """
6
+ import gradio as gr
7
+ from text2vec import Similarity
8
+
9
+ # 中文句向量模型(CoSENT)
10
+ sim_model = Similarity(model_name_or_path='shibing624/text2vec-base-chinese',
11
+ similarity_type='cosine', embedding_type='sbert')
12
+
13
+
14
+ def ai_text(sentence1, sentence2):
15
+ score = sim_model.get_score(sentence1, sentence2)
16
+ print("{} \t\t {} \t\t Score: {:.4f}".format(sentence1, sentence2, score))
17
+
18
+ return score
19
+
20
+
21
+ if __name__ == '__main__':
22
+ examples = [
23
+ ['如何更换花呗绑定银行卡', '花呗更改绑定银行卡'],
24
+ ['我在北京打篮球', '我是北京人,我喜欢篮球'],
25
+ ['一个女人在看书。', '一个女人在揉面团'],
26
+ ['一个男人在车库里举重。', '一个人在举重。'],
27
+ ]
28
+ input1 = gr.inputs.Textbox(lines=2, placeholder="Enter First Sentence")
29
+ input2 = gr.inputs.Textbox(lines=2, placeholder="Enter Second Sentence")
30
+
31
+ output_text = gr.outputs.Textbox()
32
+ gr.Interface(ai_text,
33
+ inputs=[input1, input2],
34
+ outputs=[output_text],
35
+ theme="grass",
36
+ title="Chinese Text to Vector Model shibing624/text2vec-base-chinese",
37
+ description="Copy or input Chinese text here. Submit and the machine will calculate the cosine score.",
38
+ article="Link to <a href='https://github.com/shibing624/text2vec' style='color:blue;' target='_blank\'>Github REPO</a>",
39
+ examples=examples
40
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch
4
+ text2vec