{"id":17025462,"url":"https://github.com/jackyzha0/treehacks2020-backend","last_synced_at":"2026-05-04T22:36:14.735Z","repository":{"id":103522100,"uuid":"240769623","full_name":"jackyzha0/treehacks2020-backend","owner":"jackyzha0","description":"[🏆 Azure Prize at TreeHacks] readAR -- 🌲 TreeHacks 2020 Backend","archived":false,"fork":false,"pushed_at":"2020-02-17T22:21:01.000Z","size":9840,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-19T08:49:53.791Z","etag":null,"topics":["azure","bert","flask","treehacks","word-sense-disambiguation","wsd"],"latest_commit_sha":null,"homepage":"https://devpost.com/software/readar-twh41m?fbclid=IwAR0QCuTZttAxUpiMn0I60vGjkbjpt65ha5JKyDOS-Qz7dcf3cRuCn-zZTVs","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackyzha0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-15T18:45:32.000Z","updated_at":"2022-04-08T11:14:56.000Z","dependencies_parsed_at":"2023-03-11T14:45:23.009Z","dependency_job_id":null,"html_url":"https://github.com/jackyzha0/treehacks2020-backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jackyzha0/treehacks2020-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackyzha0%2Ftreehacks2020-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackyzha0%2Ftreehacks2020-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackyzha0%2Ftreehacks2020-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackyzha0%2Ftreehacks2020-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackyzha0","download_url":"https://codeload.github.com/jackyzha0/treehacks2020-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackyzha0%2Ftreehacks2020-backend/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266506170,"owners_count":23940019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","bert","flask","treehacks","word-sense-disambiguation","wsd"],"created_at":"2024-10-14T07:29:16.389Z","updated_at":"2026-05-04T22:36:14.705Z","avatar_url":"https://github.com/jackyzha0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# readAR - backend\n[DevPost](https://devpost.com/software/readar-twh41m)\n\nThis repository contains the implementation of readAR's backend. You can find an implementation of BERT to peform word sense disambiguation served through a Flask API, as well as our image processing pipeline (`/API-azure-pipeline`). \n\nWord Sense Disambiguation is the problem of determining which \"sense\" (meaning) of a word in the context of a sentence. This model is fine-tuned on the SemEval-2007 dataset and achieves 76.6% F1% score on the test dataset (`semcor.xml`). This is comparable to the current SOTA which achieves 81.2% F1% on the same dataset. The work here builds upon this paper,\n\n\u003e Wiedemann, G., Remus, S., Chawla, A., Biemann, C. (2019): [Does BERT Make Any Sense? Interpretable Word Sense Disambiguation with Contextualized Embeddings. Proceedings of KONVENS 2019](https://www.inf.uni-hamburg.de/en/inst/ab/lt/publications/2019-wiedemannetal-bert-sense.pdf), Erlangen, Germany.\n\n### Running the example\nThe entire working model can be found as a Docker image. You can download it and run it as follows:\n\n1. `docker pull jzhao2k19/bert-wsd:latest`\n2. `docker run -p 5000:5000 jzhao2k19/bert-wsd:latest`\n\n## How to train a new model\nRun `chmod +x train.sh` to be able to run the script, then do `./train.sh` to begin training. It will take approximately 2 hours to retrain the embeddings. This will generate a new set of weights in a file called `BERT_semcor.pickle`. \n\n#### Serving the model (without Docker)\nRun `python server.py` to start a Flask server on `localhost:5000`. Hit it with a POST on `/api/wsd` with a form response containing a `sentence` and target `word`. First spin-up will take ~10s and any subsequent requests will take around 500ms. Keep in mind that running this will have required you to have trained a model before hand. If you would like to run one without training, look at `Running the example` for how to do it through docker.\n\n## Service URLs\n(may not work after the hackathon)\n* WSD-model: `140.238.147.73:5000/api/wsd`\n* img-pipeline: `140.238.147.73:8080/api`\n* quiz-generation: `140.238.147.73:8081/api?q=some+query`\n\n## Examples\n### 1 -- physics definition of work\n```bash\ncurl --location --request POST '140.238.147.73:5000/api/wsd' \\\n--form 'sentence=How much work is done to lift a 3kg object 2 meters' \\\n--form 'word=work'\n```\n\n```json\n{\n    \"def\": \"(physics) a manifestation of energy; the transfer of energy from one physical system to another expressed as the product of a force and the distance through which it moves a body in the direction of that force\"\n}\n```\n\n### 1 -- an occupational definition of work\n```bash\ncurl --location --request POST '140.238.147.73:5000/api/wsd' \\\n--form 'sentence=What do you do for work?' \\\n--form 'word=work'\n```\n\n```json\n{\n    \"def\": \"the occupation for which you are paid\"\n}\n```\n\n### 2 -- a river bank\n\n```bash\ncurl --location --request POST '140.238.147.73:5000/api/wsd' \\\n--form 'sentence=I stand on the river bank' \\\n--form 'word=bank'\n```\n\n```json\n{\n    \"def\": \"sloping land (especially the slope beside a body of water)\"\n}\n```\n\n### 2 -- a financial institution\n\n```bash\ncurl --location --request POST '140.238.147.73:5000/api/wsd' \\\n--form 'sentence=I need to deposit money at the bank tomorrow' \\\n--form 'word=bank'\n```\n\n```json\n{\n    \"def\": \"a financial institution that accepts deposits and channels the money into lending activities\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackyzha0%2Ftreehacks2020-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackyzha0%2Ftreehacks2020-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackyzha0%2Ftreehacks2020-backend/lists"}