Spaces:
Sleeping
Sleeping
vasilee
commited on
Commit
•
773bf01
0
Parent(s):
Duplicate from vasilee/flan-t5
Browse files- .gitattributes +35 -0
- Dockerfile +20 -0
- README.md +12 -0
- ct2fast-flan-alpaca-xl/.gitattributes +34 -0
- ct2fast-flan-alpaca-xl/README.md +41 -0
- ct2fast-flan-alpaca-xl/config.json +8 -0
- ct2fast-flan-alpaca-xl/model.bin +3 -0
- ct2fast-flan-alpaca-xl/model.binZone.Identifier +4 -0
- ct2fast-flan-alpaca-xl/shared_vocabulary.txt +0 -0
- ct2fast-flan-alpaca-xl/tokenizer.json +0 -0
- ct2fast-flan-alpaca-xl/tokenizer_config.json +112 -0
- ct2fast-flan-alpaca-xxl/.gitattributes +34 -0
- ct2fast-flan-alpaca-xxl/README.md +38 -0
- ct2fast-flan-alpaca-xxl/config.json +8 -0
- ct2fast-flan-alpaca-xxl/model.bin +3 -0
- ct2fast-flan-alpaca-xxl/model.binZone.Identifier +4 -0
- ct2fast-flan-alpaca-xxl/shared_vocabulary.txt +0 -0
- ct2fast-flan-alpaca-xxl/tokenizer.json +0 -0
- ct2fast-flan-alpaca-xxl/tokenizer_config.json +112 -0
- main.py +105 -0
- models/readme.txt +0 -0
- multilingual-e5-base/config.json +26 -0
- multilingual-e5-base/pytorch_model.bin +3 -0
- multilingual-e5-base/special_tokens_map.json +15 -0
- multilingual-e5-base/tokenizer.json +3 -0
- multilingual-e5-base/tokenizer_config.json +19 -0
- requirements.txt +6 -0
- static/index.html +36 -0
- static/script.js +21 -0
- static/style.css +45 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
multilingual-e5-base/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./* /code
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
RUN useradd -m -u 1000 user
|
10 |
+
|
11 |
+
USER user
|
12 |
+
|
13 |
+
ENV HOME=/home/user \
|
14 |
+
PATH=/home/user/.local/bin:$PATH
|
15 |
+
|
16 |
+
WORKDIR $HOME/app
|
17 |
+
|
18 |
+
COPY --chown=user . $HOME/app
|
19 |
+
|
20 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Difussion
|
3 |
+
emoji: 💻
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
app_port: 7860
|
9 |
+
duplicated_from: vasilee/flan-t5
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
ct2fast-flan-alpaca-xl/.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
ct2fast-flan-alpaca-xl/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- ctranslate2
|
5 |
+
- t5
|
6 |
+
---
|
7 |
+
# Fast-Inference with Ctranslate2
|
8 |
+
Speedup inference by 2x-8x using int8 inference in C++
|
9 |
+
|
10 |
+
quantized version of [declare-lab/flan-alpaca-xl](https://huggingface.co/declare-lab/flan-alpaca-xl)
|
11 |
+
```bash
|
12 |
+
pip install hf_hub_ctranslate2>=1.0.0 ctranslate2>=3.13.0
|
13 |
+
```
|
14 |
+
|
15 |
+
|
16 |
+
Checkpoint compatible to [ctranslate2](https://github.com/OpenNMT/CTranslate2) and [hf-hub-ctranslate2](https://github.com/michaelfeil/hf-hub-ctranslate2)
|
17 |
+
- `compute_type=int8_float16` for `device="cuda"`
|
18 |
+
- `compute_type=int8` for `device="cpu"`
|
19 |
+
|
20 |
+
```python
|
21 |
+
from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
|
22 |
+
|
23 |
+
model_name = "michaelfeil/ct2fast-flan-alpaca-xl"
|
24 |
+
model = TranslatorCT2fromHfHub(
|
25 |
+
# load in int8 on CUDA
|
26 |
+
model_name_or_path=model_name,
|
27 |
+
device="cuda",
|
28 |
+
compute_type="int8_float16"
|
29 |
+
)
|
30 |
+
outputs = model.generate(
|
31 |
+
text=["How do you call a fast Flan-ingo?", "Translate to german: How are you doing?"],
|
32 |
+
min_decoding_length=24,
|
33 |
+
max_decoding_length=32,
|
34 |
+
max_input_length=512,
|
35 |
+
beam_size=5
|
36 |
+
)
|
37 |
+
print(outputs)
|
38 |
+
```
|
39 |
+
|
40 |
+
# Licence and other remarks:
|
41 |
+
This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
|
ct2fast-flan-alpaca-xl/config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_source_bos": false,
|
3 |
+
"add_source_eos": false,
|
4 |
+
"bos_token": "<pad>",
|
5 |
+
"decoder_start_token": "<pad>",
|
6 |
+
"eos_token": "</s>",
|
7 |
+
"unk_token": "<unk>"
|
8 |
+
}
|
ct2fast-flan-alpaca-xl/model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25ec76282de12f1112ab018bcad38720ba4ffab251c2306189611f744dacd2f2
|
3 |
+
size 2855042120
|
ct2fast-flan-alpaca-xl/model.binZone.Identifier
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[ZoneTransfer]
|
2 |
+
ZoneId=3
|
3 |
+
ReferrerUrl=https://huggingface.co/
|
4 |
+
HostUrl=https://cdn-lfs.huggingface.co/repos/8a/63/8a63edf3c9d3d772c9237477d38cb19c1a2b7cb517f4b603333bf71596dcb871/25ec76282de12f1112ab018bcad38720ba4ffab251c2306189611f744dacd2f2?response-content-disposition=attachment%3B+filename*%3DUTF-8%27%27model.bin%3B+filename%3D%22model.bin%22%3B&response-content-type=application%2Foctet-stream&Expires=1686473535&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZG4tbGZzLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzhhLzYzLzhhNjNlZGYzYzlkM2Q3NzJjOTIzNzQ3N2QzOGNiMTljMWEyYjdjYjUxN2Y0YjYwMzMzM2JmNzE1OTZkY2I4NzEvMjVlYzc2MjgyZGUxMmYxMTEyYWIwMThiY2FkMzg3MjBiYTRmZmFiMjUxYzIzMDYxODk2MTFmNzQ0ZGFjZDJmMj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2ODY0NzM1MzV9fX1dfQ__&Signature=g%7EwPP6k9jIshth2rOqXNkxa0ZECt%7EpGz5aYLQdsgRLKzEhLGU6yra8hQREUsy-FLXFhUvDi0AFEGG-CyRKLPMVpATb6oxOalBoDr%7ENxMa2cIfbUImF4Mhg-apUCs09y%7Elk16h9Vw5AAoTAbFO-B11%7Ed8V68rPZiylFNuGYSQSK7VSona123gSbeOmMogKpan2LHpyoJCXjvV8S15IPSfEJbXhE8wQoxEitt1NbKcKlH0ViyLfQcn2IoDc1DEWPQr1zuFqhWZug4V0ptN7TxkK8hL1wwUAfm9Bf6o1xZq7xASToKkFsi2N%7EoJ-XikUC-cwUi5UvFy5DQS7VmCTEcohw__&Key-Pair-Id=KVTP0A1DKRTAX
|
ct2fast-flan-alpaca-xl/shared_vocabulary.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
ct2fast-flan-alpaca-xl/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
ct2fast-flan-alpaca-xl/tokenizer_config.json
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<extra_id_0>",
|
4 |
+
"<extra_id_1>",
|
5 |
+
"<extra_id_2>",
|
6 |
+
"<extra_id_3>",
|
7 |
+
"<extra_id_4>",
|
8 |
+
"<extra_id_5>",
|
9 |
+
"<extra_id_6>",
|
10 |
+
"<extra_id_7>",
|
11 |
+
"<extra_id_8>",
|
12 |
+
"<extra_id_9>",
|
13 |
+
"<extra_id_10>",
|
14 |
+
"<extra_id_11>",
|
15 |
+
"<extra_id_12>",
|
16 |
+
"<extra_id_13>",
|
17 |
+
"<extra_id_14>",
|
18 |
+
"<extra_id_15>",
|
19 |
+
"<extra_id_16>",
|
20 |
+
"<extra_id_17>",
|
21 |
+
"<extra_id_18>",
|
22 |
+
"<extra_id_19>",
|
23 |
+
"<extra_id_20>",
|
24 |
+
"<extra_id_21>",
|
25 |
+
"<extra_id_22>",
|
26 |
+
"<extra_id_23>",
|
27 |
+
"<extra_id_24>",
|
28 |
+
"<extra_id_25>",
|
29 |
+
"<extra_id_26>",
|
30 |
+
"<extra_id_27>",
|
31 |
+
"<extra_id_28>",
|
32 |
+
"<extra_id_29>",
|
33 |
+
"<extra_id_30>",
|
34 |
+
"<extra_id_31>",
|
35 |
+
"<extra_id_32>",
|
36 |
+
"<extra_id_33>",
|
37 |
+
"<extra_id_34>",
|
38 |
+
"<extra_id_35>",
|
39 |
+
"<extra_id_36>",
|
40 |
+
"<extra_id_37>",
|
41 |
+
"<extra_id_38>",
|
42 |
+
"<extra_id_39>",
|
43 |
+
"<extra_id_40>",
|
44 |
+
"<extra_id_41>",
|
45 |
+
"<extra_id_42>",
|
46 |
+
"<extra_id_43>",
|
47 |
+
"<extra_id_44>",
|
48 |
+
"<extra_id_45>",
|
49 |
+
"<extra_id_46>",
|
50 |
+
"<extra_id_47>",
|
51 |
+
"<extra_id_48>",
|
52 |
+
"<extra_id_49>",
|
53 |
+
"<extra_id_50>",
|
54 |
+
"<extra_id_51>",
|
55 |
+
"<extra_id_52>",
|
56 |
+
"<extra_id_53>",
|
57 |
+
"<extra_id_54>",
|
58 |
+
"<extra_id_55>",
|
59 |
+
"<extra_id_56>",
|
60 |
+
"<extra_id_57>",
|
61 |
+
"<extra_id_58>",
|
62 |
+
"<extra_id_59>",
|
63 |
+
"<extra_id_60>",
|
64 |
+
"<extra_id_61>",
|
65 |
+
"<extra_id_62>",
|
66 |
+
"<extra_id_63>",
|
67 |
+
"<extra_id_64>",
|
68 |
+
"<extra_id_65>",
|
69 |
+
"<extra_id_66>",
|
70 |
+
"<extra_id_67>",
|
71 |
+
"<extra_id_68>",
|
72 |
+
"<extra_id_69>",
|
73 |
+
"<extra_id_70>",
|
74 |
+
"<extra_id_71>",
|
75 |
+
"<extra_id_72>",
|
76 |
+
"<extra_id_73>",
|
77 |
+
"<extra_id_74>",
|
78 |
+
"<extra_id_75>",
|
79 |
+
"<extra_id_76>",
|
80 |
+
"<extra_id_77>",
|
81 |
+
"<extra_id_78>",
|
82 |
+
"<extra_id_79>",
|
83 |
+
"<extra_id_80>",
|
84 |
+
"<extra_id_81>",
|
85 |
+
"<extra_id_82>",
|
86 |
+
"<extra_id_83>",
|
87 |
+
"<extra_id_84>",
|
88 |
+
"<extra_id_85>",
|
89 |
+
"<extra_id_86>",
|
90 |
+
"<extra_id_87>",
|
91 |
+
"<extra_id_88>",
|
92 |
+
"<extra_id_89>",
|
93 |
+
"<extra_id_90>",
|
94 |
+
"<extra_id_91>",
|
95 |
+
"<extra_id_92>",
|
96 |
+
"<extra_id_93>",
|
97 |
+
"<extra_id_94>",
|
98 |
+
"<extra_id_95>",
|
99 |
+
"<extra_id_96>",
|
100 |
+
"<extra_id_97>",
|
101 |
+
"<extra_id_98>",
|
102 |
+
"<extra_id_99>"
|
103 |
+
],
|
104 |
+
"eos_token": "</s>",
|
105 |
+
"extra_ids": 100,
|
106 |
+
"model_max_length": 512,
|
107 |
+
"pad_token": "<pad>",
|
108 |
+
"sp_model_kwargs": {},
|
109 |
+
"special_tokens_map_file": "/home/arthur_huggingface_co/.cache/huggingface/hub/models--google--t5-v1_1-small/snapshots/fb7e6cba609f7bab11c614294bc04f82f613c7b1/special_tokens_map.json",
|
110 |
+
"tokenizer_class": "T5Tokenizer",
|
111 |
+
"unk_token": "<unk>"
|
112 |
+
}
|
ct2fast-flan-alpaca-xxl/.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
ct2fast-flan-alpaca-xxl/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
# Fast-Inference with Ctranslate2
|
5 |
+
Speedup inference by 2x-8x using int8 inference in C++
|
6 |
+
|
7 |
+
quantized version of [declare-lab/flan-alpaca-xxl](https://huggingface.co/declare-lab/flan-alpaca-xxl)
|
8 |
+
```bash
|
9 |
+
pip install hf_hub_ctranslate2>=1.0.0 ctranslate2>=3.13.0
|
10 |
+
```
|
11 |
+
|
12 |
+
|
13 |
+
Checkpoint compatible to [ctranslate2](https://github.com/OpenNMT/CTranslate2) and [hf-hub-ctranslate2](https://github.com/michaelfeil/hf-hub-ctranslate2)
|
14 |
+
- `compute_type=int8_float16` for `device="cuda"`
|
15 |
+
- `compute_type=int8` for `device="cpu"`
|
16 |
+
|
17 |
+
```python
|
18 |
+
from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
|
19 |
+
|
20 |
+
model_name = "michaelfeil/ct2fast-flan-alpaca-xxl"
|
21 |
+
model = TranslatorCT2fromHfHub(
|
22 |
+
# load in int8 on CUDA
|
23 |
+
model_name_or_path=model_name,
|
24 |
+
device="cuda",
|
25 |
+
compute_type="int8_float16"
|
26 |
+
)
|
27 |
+
outputs = model.generate(
|
28 |
+
text=["How do you call a fast Flan-ingo?", "Translate to german: How are you doing?"],
|
29 |
+
min_decoding_length=24,
|
30 |
+
max_decoding_length=32,
|
31 |
+
max_input_length=512,
|
32 |
+
beam_size=5
|
33 |
+
)
|
34 |
+
print(outputs)
|
35 |
+
```
|
36 |
+
|
37 |
+
# Licence and other remarks:
|
38 |
+
This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
|
ct2fast-flan-alpaca-xxl/config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_source_bos": false,
|
3 |
+
"add_source_eos": false,
|
4 |
+
"bos_token": "<pad>",
|
5 |
+
"decoder_start_token": "<pad>",
|
6 |
+
"eos_token": "</s>",
|
7 |
+
"unk_token": "<unk>"
|
8 |
+
}
|
ct2fast-flan-alpaca-xxl/model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:35c0fd62b8f7b49175264ca887ade36a77587b86fb40ea23bb372fd7c20e4ed9
|
3 |
+
size 11145587784
|
ct2fast-flan-alpaca-xxl/model.binZone.Identifier
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[ZoneTransfer]
|
2 |
+
ZoneId=3
|
3 |
+
ReferrerUrl=https://huggingface.co/
|
4 |
+
HostUrl=https://cdn-lfs.huggingface.co/repos/0c/e1/0ce18c05aa8fb558cfacca62a2d6625c9eb548ec37d26f2cfaa611e3bf1d1c5b/35c0fd62b8f7b49175264ca887ade36a77587b86fb40ea23bb372fd7c20e4ed9?response-content-disposition=attachment%3B+filename*%3DUTF-8%27%27model.bin%3B+filename%3D%22model.bin%22%3B&response-content-type=application%2Foctet-stream&Expires=1686601840&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZG4tbGZzLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzBjL2UxLzBjZTE4YzA1YWE4ZmI1NThjZmFjY2E2MmEyZDY2MjVjOWViNTQ4ZWMzN2QyNmYyY2ZhYTYxMWUzYmYxZDFjNWIvMzVjMGZkNjJiOGY3YjQ5MTc1MjY0Y2E4ODdhZGUzNmE3NzU4N2I4NmZiNDBlYTIzYmIzNzJmZDdjMjBlNGVkOT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2ODY2MDE4NDB9fX1dfQ__&Signature=QG7QwbKOOe-4aiyQP1tzsZ2rEcmkls8%7EYrccmU5GNJ3Coc1%7ERzfmAvpjUiuFCqNrmEQaBgE8iVwlMW8xmc%7ExViykk9Xcd8riioauLemZ4X792KTeT8tAeraCpWIvqxhW%7E6PIX-eMBEDJfi38b8eD7cINlY71FruKrATpVFlrOXQOKbpkT2KETNop4efmGlmF11MDh5r31yYP-jAsG8P71dfsYSGGLk2bJqOea07RBG0O6DpRojnLfEvbxe8yN65XzEhygJ9ffehjRqlDTmD8F67eWzyZUpvEl69869JMbLkfy7EdPiYfROAH4R%7EMhdYzK6NyzoOVj18ErX83MEEobg__&Key-Pair-Id=KVTP0A1DKRTAX
|
ct2fast-flan-alpaca-xxl/shared_vocabulary.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
ct2fast-flan-alpaca-xxl/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
ct2fast-flan-alpaca-xxl/tokenizer_config.json
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<extra_id_0>",
|
4 |
+
"<extra_id_1>",
|
5 |
+
"<extra_id_2>",
|
6 |
+
"<extra_id_3>",
|
7 |
+
"<extra_id_4>",
|
8 |
+
"<extra_id_5>",
|
9 |
+
"<extra_id_6>",
|
10 |
+
"<extra_id_7>",
|
11 |
+
"<extra_id_8>",
|
12 |
+
"<extra_id_9>",
|
13 |
+
"<extra_id_10>",
|
14 |
+
"<extra_id_11>",
|
15 |
+
"<extra_id_12>",
|
16 |
+
"<extra_id_13>",
|
17 |
+
"<extra_id_14>",
|
18 |
+
"<extra_id_15>",
|
19 |
+
"<extra_id_16>",
|
20 |
+
"<extra_id_17>",
|
21 |
+
"<extra_id_18>",
|
22 |
+
"<extra_id_19>",
|
23 |
+
"<extra_id_20>",
|
24 |
+
"<extra_id_21>",
|
25 |
+
"<extra_id_22>",
|
26 |
+
"<extra_id_23>",
|
27 |
+
"<extra_id_24>",
|
28 |
+
"<extra_id_25>",
|
29 |
+
"<extra_id_26>",
|
30 |
+
"<extra_id_27>",
|
31 |
+
"<extra_id_28>",
|
32 |
+
"<extra_id_29>",
|
33 |
+
"<extra_id_30>",
|
34 |
+
"<extra_id_31>",
|
35 |
+
"<extra_id_32>",
|
36 |
+
"<extra_id_33>",
|
37 |
+
"<extra_id_34>",
|
38 |
+
"<extra_id_35>",
|
39 |
+
"<extra_id_36>",
|
40 |
+
"<extra_id_37>",
|
41 |
+
"<extra_id_38>",
|
42 |
+
"<extra_id_39>",
|
43 |
+
"<extra_id_40>",
|
44 |
+
"<extra_id_41>",
|
45 |
+
"<extra_id_42>",
|
46 |
+
"<extra_id_43>",
|
47 |
+
"<extra_id_44>",
|
48 |
+
"<extra_id_45>",
|
49 |
+
"<extra_id_46>",
|
50 |
+
"<extra_id_47>",
|
51 |
+
"<extra_id_48>",
|
52 |
+
"<extra_id_49>",
|
53 |
+
"<extra_id_50>",
|
54 |
+
"<extra_id_51>",
|
55 |
+
"<extra_id_52>",
|
56 |
+
"<extra_id_53>",
|
57 |
+
"<extra_id_54>",
|
58 |
+
"<extra_id_55>",
|
59 |
+
"<extra_id_56>",
|
60 |
+
"<extra_id_57>",
|
61 |
+
"<extra_id_58>",
|
62 |
+
"<extra_id_59>",
|
63 |
+
"<extra_id_60>",
|
64 |
+
"<extra_id_61>",
|
65 |
+
"<extra_id_62>",
|
66 |
+
"<extra_id_63>",
|
67 |
+
"<extra_id_64>",
|
68 |
+
"<extra_id_65>",
|
69 |
+
"<extra_id_66>",
|
70 |
+
"<extra_id_67>",
|
71 |
+
"<extra_id_68>",
|
72 |
+
"<extra_id_69>",
|
73 |
+
"<extra_id_70>",
|
74 |
+
"<extra_id_71>",
|
75 |
+
"<extra_id_72>",
|
76 |
+
"<extra_id_73>",
|
77 |
+
"<extra_id_74>",
|
78 |
+
"<extra_id_75>",
|
79 |
+
"<extra_id_76>",
|
80 |
+
"<extra_id_77>",
|
81 |
+
"<extra_id_78>",
|
82 |
+
"<extra_id_79>",
|
83 |
+
"<extra_id_80>",
|
84 |
+
"<extra_id_81>",
|
85 |
+
"<extra_id_82>",
|
86 |
+
"<extra_id_83>",
|
87 |
+
"<extra_id_84>",
|
88 |
+
"<extra_id_85>",
|
89 |
+
"<extra_id_86>",
|
90 |
+
"<extra_id_87>",
|
91 |
+
"<extra_id_88>",
|
92 |
+
"<extra_id_89>",
|
93 |
+
"<extra_id_90>",
|
94 |
+
"<extra_id_91>",
|
95 |
+
"<extra_id_92>",
|
96 |
+
"<extra_id_93>",
|
97 |
+
"<extra_id_94>",
|
98 |
+
"<extra_id_95>",
|
99 |
+
"<extra_id_96>",
|
100 |
+
"<extra_id_97>",
|
101 |
+
"<extra_id_98>",
|
102 |
+
"<extra_id_99>"
|
103 |
+
],
|
104 |
+
"eos_token": "</s>",
|
105 |
+
"extra_ids": 100,
|
106 |
+
"model_max_length": 512,
|
107 |
+
"pad_token": "<pad>",
|
108 |
+
"sp_model_kwargs": {},
|
109 |
+
"special_tokens_map_file": "/home/arthur_huggingface_co/.cache/huggingface/hub/models--google--t5-v1_1-small/snapshots/fb7e6cba609f7bab11c614294bc04f82f613c7b1/special_tokens_map.json",
|
110 |
+
"tokenizer_class": "T5Tokenizer",
|
111 |
+
"unk_token": "<unk>"
|
112 |
+
}
|
main.py
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from torch import Tensor
|
2 |
+
from transformers import AutoTokenizer, AutoModel
|
3 |
+
from ctranslate2 import Translator
|
4 |
+
from typing import Union
|
5 |
+
|
6 |
+
from fastapi import FastAPI
|
7 |
+
from pydantic import BaseModel
|
8 |
+
|
9 |
+
|
10 |
+
def average_pool(last_hidden_states: Tensor,
|
11 |
+
attention_mask: Tensor) -> Tensor:
|
12 |
+
last_hidden = last_hidden_states.masked_fill(
|
13 |
+
~attention_mask[..., None].bool(), 0.0)
|
14 |
+
return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
|
15 |
+
|
16 |
+
|
17 |
+
# text-ada replacement
|
18 |
+
embeddingTokenizer = AutoTokenizer.from_pretrained(
|
19 |
+
'./multilingual-e5-base')
|
20 |
+
embeddingModel = AutoModel.from_pretrained('./multilingual-e5-base')
|
21 |
+
|
22 |
+
# chatGpt replacement
|
23 |
+
inferenceTokenizer = AutoTokenizer.from_pretrained(
|
24 |
+
"./ct2fast-flan-alpaca-xl")
|
25 |
+
inferenceTranslator = Translator(
|
26 |
+
"./ct2fast-flan-alpaca-xl", compute_type="int8", device="cpu")
|
27 |
+
|
28 |
+
|
29 |
+
class EmbeddingRequest(BaseModel):
|
30 |
+
input: Union[str, None] = None
|
31 |
+
|
32 |
+
|
33 |
+
class TokensCountRequest(BaseModel):
|
34 |
+
input: Union[str, None] = None
|
35 |
+
|
36 |
+
|
37 |
+
class InferenceRequest(BaseModel):
|
38 |
+
input: Union[str, None] = None
|
39 |
+
max_length: Union[int, None] = 0
|
40 |
+
|
41 |
+
|
42 |
+
app = FastAPI()
|
43 |
+
|
44 |
+
|
45 |
+
@app.get("/")
|
46 |
+
async def root():
|
47 |
+
return {"message": "Hello World"}
|
48 |
+
|
49 |
+
|
50 |
+
@app.post("/text-embedding")
|
51 |
+
async def text_embedding(request: EmbeddingRequest):
|
52 |
+
input = request.input
|
53 |
+
|
54 |
+
# Process the input data
|
55 |
+
batch_dict = embeddingTokenizer([input], max_length=512,
|
56 |
+
padding=True, truncation=True, return_tensors='pt')
|
57 |
+
outputs = embeddingModel(**batch_dict)
|
58 |
+
embeddings = average_pool(outputs.last_hidden_state,
|
59 |
+
batch_dict['attention_mask'])
|
60 |
+
|
61 |
+
# create response
|
62 |
+
return {
|
63 |
+
'embedding': embeddings[0].tolist()
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
@app.post('/inference')
|
68 |
+
async def inference(request: InferenceRequest):
|
69 |
+
input_text = request.input
|
70 |
+
max_length = 256
|
71 |
+
try:
|
72 |
+
max_length = int(request.max_length)
|
73 |
+
max_length = min(1024, max_length)
|
74 |
+
except:
|
75 |
+
pass
|
76 |
+
|
77 |
+
# process request
|
78 |
+
input_tokens = inferenceTokenizer.convert_ids_to_tokens(
|
79 |
+
inferenceTokenizer.encode(input_text))
|
80 |
+
|
81 |
+
results = inferenceTranslator.translate_batch(
|
82 |
+
[input_tokens], beam_size=1, max_input_length=0, max_decoding_length=max_length, num_hypotheses=1, repetition_penalty=1.3, sampling_topk=40, sampling_temperature=0.7, use_vmap=False)
|
83 |
+
|
84 |
+
output_tokens = results[0].hypotheses[0]
|
85 |
+
output_text = inferenceTokenizer.decode(
|
86 |
+
inferenceTokenizer.convert_tokens_to_ids(output_tokens))
|
87 |
+
|
88 |
+
# create response
|
89 |
+
return {
|
90 |
+
'generated_text': output_text
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
@app.post('/tokens-count')
|
95 |
+
async def tokens_count(request: TokensCountRequest):
|
96 |
+
input_text = request.input
|
97 |
+
|
98 |
+
tokens = inferenceTokenizer.convert_ids_to_tokens(
|
99 |
+
inferenceTokenizer.encode(input_text))
|
100 |
+
|
101 |
+
# create response
|
102 |
+
return {
|
103 |
+
'tokens': tokens,
|
104 |
+
'total': len(tokens)
|
105 |
+
}
|
models/readme.txt
ADDED
File without changes
|
multilingual-e5-base/config.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "intfloat/multilingual-e5-base",
|
3 |
+
"architectures": ["XLMRobertaModel"],
|
4 |
+
"attention_probs_dropout_prob": 0.1,
|
5 |
+
"bos_token_id": 0,
|
6 |
+
"classifier_dropout": null,
|
7 |
+
"eos_token_id": 2,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.1,
|
10 |
+
"hidden_size": 768,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 3072,
|
13 |
+
"layer_norm_eps": 1e-5,
|
14 |
+
"max_position_embeddings": 514,
|
15 |
+
"model_type": "xlm-roberta",
|
16 |
+
"num_attention_heads": 12,
|
17 |
+
"num_hidden_layers": 12,
|
18 |
+
"output_past": true,
|
19 |
+
"pad_token_id": 1,
|
20 |
+
"position_embedding_type": "absolute",
|
21 |
+
"torch_dtype": "float32",
|
22 |
+
"transformers_version": "4.29.2",
|
23 |
+
"type_vocab_size": 1,
|
24 |
+
"use_cache": true,
|
25 |
+
"vocab_size": 250002
|
26 |
+
}
|
multilingual-e5-base/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f061cb7641880f52895cbacab7c4ab39b0844e2e6b73794f2798de460d9fa418
|
3 |
+
size 1112242989
|
multilingual-e5-base/special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "<mask>",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "</s>",
|
14 |
+
"unk_token": "<unk>"
|
15 |
+
}
|
multilingual-e5-base/tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:62c24cdc13d4c9952d63718d6c9fa4c287974249e16b7ade6d5a85e7bbb75626
|
3 |
+
size 17082660
|
multilingual-e5-base/tokenizer_config.json
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"clean_up_tokenization_spaces": true,
|
4 |
+
"cls_token": "<s>",
|
5 |
+
"eos_token": "</s>",
|
6 |
+
"mask_token": {
|
7 |
+
"__type": "AddedToken",
|
8 |
+
"content": "<mask>",
|
9 |
+
"lstrip": true,
|
10 |
+
"normalized": true,
|
11 |
+
"rstrip": false,
|
12 |
+
"single_word": false
|
13 |
+
},
|
14 |
+
"model_max_length": 512,
|
15 |
+
"pad_token": "<pad>",
|
16 |
+
"sep_token": "</s>",
|
17 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
18 |
+
"unk_token": "<unk>"
|
19 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ctranslate2==3.14.0
|
2 |
+
fastapi==0.96.0
|
3 |
+
pydantic==1.10.8
|
4 |
+
torch==2.0.1
|
5 |
+
transformers==4.29.2
|
6 |
+
uvicorn[standard]==0.17.*
|
static/index.html
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>Fast API 🤗 Space served with Uvicorn</title>
|
7 |
+
<link rel="stylesheet" href="style.css" />
|
8 |
+
<script type="module" src="script.js"></script>
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<main>
|
12 |
+
<section id="text-gen">
|
13 |
+
<h1>Text generation using Flan T5</h1>
|
14 |
+
<p>
|
15 |
+
Model:
|
16 |
+
<a
|
17 |
+
href="https://huggingface.co/google/flan-t5-small"
|
18 |
+
rel="noreferrer"
|
19 |
+
target="_blank"
|
20 |
+
>google/flan-t5-small</a
|
21 |
+
>
|
22 |
+
</p>
|
23 |
+
<form class="text-gen-form">
|
24 |
+
<label for="text-gen-input">Text prompt</label>
|
25 |
+
<input
|
26 |
+
id="text-gen-input"
|
27 |
+
type="text"
|
28 |
+
value="English: Translate There are many ducks. German:"
|
29 |
+
/>
|
30 |
+
<button id="text-gen-submit">Submit</button>
|
31 |
+
<p class="text-gen-output"></p>
|
32 |
+
</form>
|
33 |
+
</section>
|
34 |
+
</main>
|
35 |
+
</body>
|
36 |
+
</html>
|
static/script.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const textGenForm = document.querySelector('.text-gen-form');
|
2 |
+
|
3 |
+
const translateText = async (text) => {
|
4 |
+
const inferResponse = await fetch(`infer_t5?input=${text}`);
|
5 |
+
const inferJson = await inferResponse.json();
|
6 |
+
|
7 |
+
return inferJson.output;
|
8 |
+
};
|
9 |
+
|
10 |
+
textGenForm.addEventListener('submit', async (event) => {
|
11 |
+
event.preventDefault();
|
12 |
+
|
13 |
+
const textGenInput = document.getElementById('text-gen-input');
|
14 |
+
const textGenParagraph = document.querySelector('.text-gen-output');
|
15 |
+
|
16 |
+
try {
|
17 |
+
textGenParagraph.textContent = await translateText(textGenInput.value);
|
18 |
+
} catch (err) {
|
19 |
+
console.error(err);
|
20 |
+
}
|
21 |
+
});
|
static/style.css
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
--text: hsl(0 0% 15%);
|
3 |
+
padding: 2.5rem;
|
4 |
+
font-family: sans-serif;
|
5 |
+
color: var(--text);
|
6 |
+
}
|
7 |
+
|
8 |
+
body.dark-theme {
|
9 |
+
--text: hsl(0 0% 90%);
|
10 |
+
background-color: hsl(223 39% 7%);
|
11 |
+
}
|
12 |
+
|
13 |
+
main {
|
14 |
+
max-width: 80rem;
|
15 |
+
text-align: center;
|
16 |
+
}
|
17 |
+
|
18 |
+
section {
|
19 |
+
display: flex;
|
20 |
+
flex-direction: column;
|
21 |
+
align-items: center;
|
22 |
+
}
|
23 |
+
|
24 |
+
a {
|
25 |
+
color: var(--text);
|
26 |
+
}
|
27 |
+
|
28 |
+
form {
|
29 |
+
width: 30rem;
|
30 |
+
margin: 0 auto;
|
31 |
+
}
|
32 |
+
|
33 |
+
input {
|
34 |
+
width: 100%;
|
35 |
+
}
|
36 |
+
|
37 |
+
button {
|
38 |
+
cursor: pointer;
|
39 |
+
}
|
40 |
+
|
41 |
+
.text-gen-output {
|
42 |
+
min-height: 1.2rem;
|
43 |
+
margin: 1rem;
|
44 |
+
border: 0.5px solid grey;
|
45 |
+
}
|