{"id":48514202,"url":"https://github.com/michael-0acf4/anitag2vec","last_synced_at":"2026-04-07T18:30:53.461Z","repository":{"id":345932784,"uuid":"1173843563","full_name":"michael-0acf4/anitag2vec","owner":"michael-0acf4","description":"Generate vector embeddings from Danbooru, Sakugabooru, Pixiv, MAL style tags.","archived":false,"fork":false,"pushed_at":"2026-04-06T16:40:33.000Z","size":23583,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-06T18:26:54.178Z","etag":null,"topics":["cosine-similarity","danbooru","deepset","myanimelist","myanimelist-filter","pixiv","pytorch","pytorch-implementation","ranking-algorithm","sakugabooru","set-embedding","tag-embedding","transformer","vector-embeddings"],"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/michael-0acf4.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-05T20:10:15.000Z","updated_at":"2026-03-29T23:09:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/michael-0acf4/anitag2vec","commit_stats":null,"previous_names":["michael-0acf4/anitag2vec"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/michael-0acf4/anitag2vec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-0acf4%2Fanitag2vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-0acf4%2Fanitag2vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-0acf4%2Fanitag2vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-0acf4%2Fanitag2vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michael-0acf4","download_url":"https://codeload.github.com/michael-0acf4/anitag2vec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-0acf4%2Fanitag2vec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31524524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cosine-similarity","danbooru","deepset","myanimelist","myanimelist-filter","pixiv","pytorch","pytorch-implementation","ranking-algorithm","sakugabooru","set-embedding","tag-embedding","transformer","vector-embeddings"],"created_at":"2026-04-07T18:30:50.976Z","updated_at":"2026-04-07T18:30:53.429Z","avatar_url":"https://github.com/michael-0acf4.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# anitag2vec\n\nanitag2vec is a vector embedding primarily focused on Danbooru, Sakugabooru, Pixiv, MAL, etc type of tags.\n\n# Why?\n\nIf you have your own local gallery or index of things you like, which, to be fair you most likely probably don't BUT having a recommendation system is quite laborious without a fuzzy component to it.\n\nI mean, sure you can do tag based statistics but you will have to manually group similar tags and somehow also account for spelling variation. With a vector embedding, problem solved! Just pin something you like then get recommended co**similar** stuff.\n\nThere are many off-the-shelf vector embeddings, but they are primarily designed for general-purpose tasks such as sentence embeddings. While you can still adapt them for other use cases, many models are sensitive to token order and the exact phrasing of inputs.\n\n# Setup\n\nThe model checkpoints are available [HERE](https://huggingface.co/michael-0acf4/anitag2vec), this includes ONNX ports.\n\n## Python\n\n```bash\npip install torch tokenizers tqdm asciichartpy\n```\n\nSee the notebook [python/ranked_inference.ipynb](python/ranked_inference.ipynb) for a concrete inference example.\n\nYou can also explore the model's capabilities by composing embeddings using +, *, -, /.\n\n```bash\npython python/interactive.py\n```\n\nHere for example, we look for the closest entries to the expression within [this MAL style dataset](./data/mal_5a250b8b201ace01.json).\n\n![Tag Algebra](misc/tag_algebra.png)\n\n## Inference in Rust\n\nThe rust implementation relies on the ONNX port of the PyTorch model.\n\n```bash\ncargo add anitag2vec\n```\n\n```rust\nuse anitag2vec::{\n    downloader::{ModelDownloader, KnownModel},\n    model::Anitag2Vec,\n    tagtok::TagSet\n};\n\nfn main() {\n    println!(\"Downloading models...\");\n    let model_path = ModelDownloader::from_known(KnownModel::Anitag2VecV1, false).download().unwrap();\n    let tokenizer_path = ModelDownloader::from_known(KnownModel::Anitag2VecTokenizerV1, false).download().unwrap();\n    println!(\"Done!\");\n\n    let mut anitag2vec = Anitag2Vec::load_from_file_v1(model_path, tokenizer_path).unwrap();\n    let example = vec![\n        TagSet::new([\"transcend\", \"uma musume\", \"imageset\", \"japanese\"]),\n        TagSet::new([\"Comedy\", \"TV\", \"Anime\", \"Romance\"]),\n    ];\n    let emb = anitag2vec.run_inference(example).unwrap();\n    println!(\"{:?}\", emb.shape()); // [2, 128]\n\n    // Similar to emb.map(|nd| ..)\n    // This representation allows various math operations\n    println!(\"{}\", emb.ndarray());\n\n    // or alternatively as Vec\u003cVec\u003cf32\u003e\u003e\n    // println!(\"{:?}\", emb.to_vec());\n}\n```\n\n# Architecture\n\nYou can refer to [my blog post](https://blog.afmichael.dev/posts/2026/set-embeddings-and-anitag2vec/) in which I detail the design decisions and also how it works.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael-0acf4%2Fanitag2vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichael-0acf4%2Fanitag2vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael-0acf4%2Fanitag2vec/lists"}