{"id":13677902,"url":"https://github.com/joisino/wordtour","last_synced_at":"2025-04-14T03:53:21.677Z","repository":{"id":37473391,"uuid":"488091508","full_name":"joisino/wordtour","owner":"joisino","description":"Code for \"Word Tour: One-dimensional Word Embeddings via the Traveling Salesman Problem\" (NAACL 2022)","archived":false,"fork":false,"pushed_at":"2022-05-06T08:50:57.000Z","size":644,"stargazers_count":92,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T17:51:59.452Z","etag":null,"topics":["embeddings","machine-learning","natural-language-processing","word-embeddings","word2vec"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joisino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-03T05:46:16.000Z","updated_at":"2025-01-12T07:10:15.000Z","dependencies_parsed_at":"2022-08-02T01:09:38.839Z","dependency_job_id":null,"html_url":"https://github.com/joisino/wordtour","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joisino%2Fwordtour","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joisino%2Fwordtour/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joisino%2Fwordtour/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joisino%2Fwordtour/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joisino","download_url":"https://codeload.github.com/joisino/wordtour/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819365,"owners_count":21166474,"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","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":["embeddings","machine-learning","natural-language-processing","word-embeddings","word2vec"],"created_at":"2024-08-02T13:00:48.375Z","updated_at":"2025-04-14T03:53:21.660Z","avatar_url":"https://github.com/joisino.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Word Tour: One-dimensional Word Embeddings via the Traveling Salesman Problem (NAACL 2022)\n\nWe proposed one-dimensional word embeddings.\n\nPaper: https://arxiv.org/abs/2205.01954\n\n![Illustration](./imgs/illust.png)\n\n## 💡 How to Use\n\n`wordtour.txt` is the trained embeddings. The i-th line shows the i-th word in the tour. Note that the embeddings are circular, and thus the first line and the last line are next to each other.\n\n## 📝 Results\n\n### Examples of segments\n\nEach row represents a segment. (a--d) Segments around \"cat.\" (e--h) Segments around \"concept.\" (i--o) Random segments of WordTour. WordTour provides smooth orderings.\n\n|     | Methods | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| (a) | WordTour | sniff | sniffing | sniffer | dogs | dog | cat | cats | pets | pet | stray | errant |\n| (b) | RandProj | loire | sayings | nn | trooper | referendum | cat | exceeded | traces | freestyle | mirrored | bloomberg |\n| (c) | PCA1 | mm | asylum | kohl | presents | expressed | cat | sichuan | denmark | counted | corporations | hewitt |\n| (d) | PCA4 | 1.46 | puzzles | 940 | coexist | locations | cat | att | winners | perth | colgate | sohail |\n| | | | | | | | | | | | | |\n| (e) | WordTour | assumption | assumptions | notions | notion | idea | concept | concepts | ideas | thoughts | feelings | emotions |\n| (f) | RandProj | entertaining | 42,000 | kursk | embarrassment | ingrained | concept | berezovsky | cg | guillen | excerpts | roofs |\n| (g) | PCA1 | neighboring | branches | argued | manhattan | 1998 | concept | share | pending | response | airlines | fort |\n| (h) | PCA4 | 2:00 | hksar | hashim | provider | straining | concept | inducing | fightback | unsettled | bavaria | sign |\n| | | | | | | | | | | | | |\n| (i) | WordTour | wireless | broadband | 3g | cdma | gsm | handset | handsets | smartphones | smartphone | blackberry | tablet |\n| (j) | WordTour | gun | weapon | weapons | arms | arm | leg | legs | limbs | limb | prosthetic | make-up |\n| (k) | WordTour | federalist | libertarian | progressive | liberal | conservative | conservatives | liberals | democrats | republicans | gop | republican |\n| (l) | WordTour | cordial | amicable | agreeable | mutually | beneficial | detrimental | harmful | destructive | disruptive | behaviour | behavior |\n| (m) | WordTour | 15th | 14th | 13th | 12th | 10th | 11th | 9th | 8th | 7th | 6th | 5th |\n| (n) | WordTour | suspicions | doubts | doubt | doubted | doubting | doubters | skeptics | skeptic | believer | believers | adherents |\n| (o) | WordTour | molten | magma | lava | basalt | sandstone | limestone | granite | marble | slab | slabs | prefabricated |\n\n### Crawdsourcing Evaluation\n\nEach bar represents the number of times each method was selected by crowdworkers within 100 trials.\n\n![Crownsourcing Evaluation](./imgs/user_study.png)\n\n### Document Classification\n\nEach cell reports a kNN classification error. Lower is better. The time row reports the average time to compare the two documents. WordTour performs the best in the blurred BoW family.\n\n| | ohsumed | reuter | 20news | amazon | classic |\n| --- | --- | --- | --- | --- | --- |\n| BoW | 48.1 | 5.6 | 35.4 | 11.4 ± 0.4 | 5.1 ± 0.3 |\n| Time | 39 ns | 23 ns | 35 ns | 21 ns | 23 ns |\n| | | | | | |\n| WordTour | **47.2** | **4.6** | **34.1** | **10.1 ± 0.3** | **4.6 ± 0.1** |\n| RandProj | 47.9 | 5.4 | 35.4 | 11.3 ± 0.3 | 5.1 ± 0.3 |\n| PCA1 | 47.8 | 5.7 | 35.5 | 11.4 ± 0.6 | 5.1 ± 0.3 |\n| PCA4 | 48.1 | 5.6 | 35.4 | 11.6 ± 0.5 | 5.1 ± 0.4 |\n| Time | 206 ns | 142 ns | 312 ns | 185 ns | 150 ns |\n| | | | | | |\n| WMD | 47.5 | 4.5 | 30.7 | 7.6 ± 0.3 | 4.2 ± 0.3 |\n| Time | 3.5 x 10^6 ns | 2.2 x 10^6 ns | 5.1 x 10^6 ns| 1.2 x 10^7 ns | 1.9 x 10^6 ns |\n\n## ⛏️ How to Build WordTour by Yourself\n\n1. Install the dependencies.\n\n```\n$ sudo apt install wget unzip build-essential\n```\n\n2. Download the GloVe embeddings and LKH solver.\n\n```\n$ ./download.sh\n```\n\n3. Compile the generator.\n\n```\n$ make\n```\n\n4. Create the LKH config file.\n\n```\n$ ./make_LKH_file\nUsage: ./make_LKH_file [embedding file path] [#words]\n$ ./make_LKH_file ./glove.6B/glove.6B.300d.txt 400 \u003e ./LKH-3.0.6/wordtour.tsp\n$ cp wordtour.par ./LKH-3.0.6/wordtour.par\n```\n\nHere, 400 is used for an illustration purpose. 40000 words may take a few minutes and consume a few GB of strage.\n\n5. Compile the LKH solver.\n\n```\n$ cd LKH-3.0.6\n$ make\n```\n\n6. Run the LKH solver.\n\n```\n$ ./LKH wordtour.par\n```\n\nNote: The result is saved in `wordtour.out`.\n\nNote: It may take several hourds to run the LKH solver with 40000 words.\n\n7. Extract the word list.\n\n```\n$ cd ..\n$ python generate_order_file.py\n$ cat wordtour.txt\n```\n\n## 🧪 How to Evaluate\n\n1. Download the Datasets.\n\nYou also need to run `./download.sh` if you haven't yet.\n\n```\n$ ./download_datasets.sh\n```\n\n2. Preprocess.\n\n```\n$ python ./preprocess.py\n```\n\n3. Evaluate.\n\nBe sure that the embeddings files, `wordtour.txt`, `order_randproj.txt`, `order_pca1.txt`, and `order_pca4.txt`, contain the embeddings you want to evaluate. It might contain only 400 words if you ran the \"How to Build WordTour by Yourself\" scripts.\n\n```\n$ python evaluate.py\n```\n\n## 🖋️ Citation\n\n```\n@inproceedings{sato2022wordtour,\n  author    = {Ryoma Sato},\n  title     = {Word Tour: One-dimensional Word Embeddings via the Traveling Salesman Problem},\n  booktitle = {Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, {NAACL-HLT}},\n  year      = {2022},\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoisino%2Fwordtour","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoisino%2Fwordtour","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoisino%2Fwordtour/lists"}