Skip to content

Commit 3511bd9

Browse files
committed
update download url and requirements for text model
1 parent 0a22418 commit 3511bd9

5 files changed

Lines changed: 25 additions & 8 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Binaries for programs and plugins
2+
*.swp
3+
__pycache__/
4+
5+
6+
#skip some test file
7+
model/
8+
src/log/
9+

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ Before inserting and searching, a database and space should be creating firstly.
4545
curl -XPUT -H "content-type:application/json" -d '{"name": "test"}' http://127.0.0.1:4101/db/_create
4646

4747
# create a space in test db which name test too.
48-
curl -XPUT -H "content-type: application/json" -d' { "name": "test", "dynamic_schema": "strict", "partition_num": 2, "replica_num": 1, "engine": {"name":"gamma","metric_type": "InnerProduct"}, "properties": { "url": { "type": "keyword", "index": true}, "feature1": { "type": "vector", "dimension":512, "format": "normalization" }}} ' http://127.0.0.1:4101/space/test/_create
48+
## for image
49+
curl -XPUT -H "content-type: application/json" -d '{"name": "test", "partition_num": 1, "replica_num": 1, "engine": {"name": "gamma", "index_size": 70000, "max_size": 10000000, "id_type": "String", "retrieval_type": "IVFPQ", "retrieval_param": { "metric_type": "InnerProduct", "ncentroids": 256, "nsubvector": 32 } }, "properties": { "url": { "type": "keyword", "index": true }, "feature1": { "type": "vector", "dimension":512, "format": "normalization" } }} }' http://127.0.0.1:4101/space/test/_create
50+
51+
## for text dimension is 768
52+
curl -XPUT -H "content-type: application/json" -d '{"name": "test", "partition_num": 1, "replica_num": 1, "engine": {"name": "gamma", "index_size": 70000, "max_size": 10000000, "id_type": "String", "retrieval_type": "IVFPQ", "retrieval_param": { "metric_type": "InnerProduct", "ncentroids": 256, "nsubvector": 32 } }, "properties": { "text": { "type": "keyword", "index": true }, "feature1": { "type": "vector", "dimension":768, "format": "normalization" } }} }' http://127.0.0.1:4101/space/test/_create
4953
```
5054

5155
A successful response looks like this:
@@ -86,8 +90,12 @@ The method of single import demo:
8690
8791
```shell
8892
# single insert
93+
94+
## image
8995
curl -XPOST -H "content-type: application/json" -d' { "url": "../images/COCO_val2014_000000123599.jpg", "feature1":{"feature":"../images/COCO_val2014_000000123599.jpg"}} ' http://127.0.0.1:4101/test/test/AW63W9I4JG6WicwQX_RC
9096

97+
## text
98+
curl -XPOST -H "content-type: application/json" -d' { "text": "感谢大家", "feature1":{"feature":"感谢大家"} } ' http://127.0.0.1:4101/test/test/AW63W9I4JG6WicwQX_RC'
9199
```
92100
93101
A successful response like this:

bin/run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
path=`pwd`
44
cd $path/src
5-
pip install -r requirements.txt
5+
# pip install -r requirements.txt
6+
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
67

78
run_image_retrieval(){
89
python main.py --model_name=image_retrieval

src/text/requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Keras==2.2.4
2-
keras-bert==0.80.0
3-
tensorboard==1.15.0
4-
tensorflow-gpu==1.15.2
1+
keras==2.4.3
2+
keras-bert==0.85.0
3+
tensorflow-gpu==2.2.0

src/text/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from keras_bert import extract_embeddings,get_checkpoint_paths,load_trained_model_from_checkpoint, load_vocabulary
1818

1919

20-
MODEL_URL = 'https://storage.googleapis.com/hfl-rc/chinese-bert/chinese_wwm_L-12_H-768_A-12.zip'
20+
MODEL_URL = 'https://storage.googleapis.com/bert_models/2018_11_03/chinese_L-12_H-768_A-12.zip'
2121

2222

2323
class Text(object):
@@ -28,7 +28,7 @@ def __init__(self, config):
2828
if not os.path.exists(model_dir):
2929
os.makedirs(model_dir)
3030
subprocess.run(
31-
f"wget -P {model_dir} {MODEL_URL} && cd {model_dir} && unzip chinese_wwm_L-12_H-768_A-12.zip",
31+
f"wget -P {model_dir} {MODEL_URL} && cd {model_dir} && unzip chinese_L-12_H-768_A-12.zip",
3232
shell=True)
3333

3434
paths = get_checkpoint_paths(model_path)

0 commit comments

Comments
 (0)