在TensorFlow(1.1.0)中實現的釋義標識的各種模型和代碼。
我非常注意記錄代碼,並在整個模型中的各個步驟中解釋了我在做什麼;希望對於那些希望開始使用TensorFlow的人來說,這將是教學示例代碼!
到目前為止,該倉庫已經實施:
基本的Siamese LSTM基線,基於Mueller,Jonas和Aditya Thyagarajan的模型。 “學習句子相似性的暹羅復發架構。” AAAI(2016)。
如Liu,Yang等人所述,具有添加“匹配層”的暹羅LSTM模型。 “使用雙向LSTM模型和內部注意力學習自然語言推斷。” CORR ABS/1605.09090(2016)。
來自Wang,Zhiguo等人的雙邊多方面匹配模型或更無效的狀態。 “與自然語言句子相匹配的雙邊多角度。” CORR ABS/1702.03814(2017)。
PR添加更多模型 /優化或修補現有的PR非常歡迎!大部分模型代碼位於副詞/型號中
許多數據處理代碼均取自Allenai / deep_qa的 /啟發,如果您喜歡該項目的結構化,請查看它們!
該項目是在Python 3.5上進行了開發的,並已在其他版本的Python上進行了測試,並且包裝要求符合requirements.txt 。
安裝要求:
pip install -r requirements.txt
請注意,安裝要求後,您必須通過運行(在外殼中)下載必要的NLTK數據:
python -m nltk.downloader punkt
請注意, requirements.txt文件將tensorflow指定為依賴項,這是TensorFlow的CPU結合版本。如果您有GPU,則應卸載此CPU TensorFlow並通過運行安裝GPU版本:
pip uninstall tensorflow
pip install tensorflow-gpu
首先,運行以下內容以生成用於存儲數據,訓練模型和日誌的輔助目錄:
make aux_dirs
此外,如果您想使用驗證的手套向量,請運行:
make glove
它將下載驗證的手套向量到data/external/ 。在同一目錄中提取文件。
要使用Quora問題對數據,請從Kaggle下載數據集(可能需要帳戶)。將下載的ZIP檔案放在data/raw/中,然後將文件提取到同一目錄。
然後,運行:
make quora_data
為了自動清潔和處理scripts/data/quora中的腳本的數據。
要使用模型訓練模型或負載 +預測,然後用python <script_path>在scripts/run_model/中運行腳本。您可以通過運行python <script_path> -h獲取有關其獲取的參數的其他文檔
這是基線暹羅比爾斯特的示例運行命令:
python scripts/run_model/run_siamese.py train --share_encoder_weights --model_name=baseline_siamese --run_id=0
這是帶有匹配層的暹羅bilstm的示例運行命令:
python scripts/run_model/run_siamese_matching_bilstm.py train --share_encoder_weights --model_name=siamese_matching --run_id=0
這是BIMPM模型的示例運行命令:
python scripts/run_model/run_bimpm.py train --early_stopping_patience=5 --model_name=biMPM --run_id=0
請注意,默認值可能不是您使用的理想選擇,因此請隨時隨意轉動旋鈕。
您對如何改善此存儲庫有想法嗎?有功能請求,錯誤報告還是補丁?隨時開放問題或公關,因為我很樂意解決問題並查看拉力請求。
├── LICENSE
├── Makefile <- Makefile with commands like `make data` or `make train`
├── README.md <- The top-level README for developers using this project.
├── data
│ ├── external <- Data from third party sources.
│ ├── interim <- Intermediate data that has been transformed.
│ ├── processed <- The final, canonical data sets for modeling.
│ └── raw <- Original immutable data (e.g. Quora Question Pairs).
|
├── logs <- Logs from training or prediction, including TF model summaries.
│
├── models <- Serialized models.
|
├── requirements.txt <- The requirements file for reproducing the analysis environment
│
├── duplicate_questions<- Module with source code for models and data.
│ ├── data <- Methods and classes for manipulating data.
│ │
│ ├── models <- Methods and classes for training models.
│ │
│ └── util <- Various helper methods and classes for use in models.
│
├── scripts <- Scripts for generating the data
│ ├── data <- Scripts to clean and split data
│ │
│ └── run_model <- Scripts to train and predict with models.
│
└── tests <- Directory with unit tests.