{"id":13879316,"url":"https://github.com/ankane/informers","last_synced_at":"2025-11-17T14:09:17.249Z","repository":{"id":42614663,"uuid":"300489205","full_name":"ankane/informers","owner":"ankane","description":"Fast transformer inference for Ruby","archived":false,"fork":false,"pushed_at":"2025-02-01T19:57:03.000Z","size":2605,"stargazers_count":589,"open_issues_count":2,"forks_count":17,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-11-09T19:05:30.957Z","etag":null,"topics":["named-entity-recognition","question-answering","sentiment-analysis"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-10-02T03:20:32.000Z","updated_at":"2025-11-08T11:29:32.000Z","dependencies_parsed_at":"2024-11-28T01:03:42.698Z","dependency_job_id":"51c0dea8-d6e6-4e75-b1a1-7c20ed410ffe","html_url":"https://github.com/ankane/informers","commit_stats":{"total_commits":188,"total_committers":3,"mean_commits":"62.666666666666664","dds":"0.010638297872340385","last_synced_commit":"332d5f851459339b7a93b09ec67ec6312bfa6067"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/informers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Finformers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Finformers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Finformers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Finformers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/informers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Finformers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284893727,"owners_count":27080568,"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-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["named-entity-recognition","question-answering","sentiment-analysis"],"created_at":"2024-08-06T08:02:17.081Z","updated_at":"2025-11-17T14:09:17.231Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Informers\n\n:fire: Fast [transformer](https://github.com/huggingface/transformers.js) inference for Ruby\n\nFor non-ONNX models, check out [Transformers.rb](https://github.com/ankane/transformers-ruby) :slightly_smiling_face:\n\n[![Build Status](https://github.com/ankane/informers/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/informers/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"informers\"\n```\n\n## Getting Started\n\n- [Models](#models)\n- [Pipelines](#pipelines)\n\n## Models\n\nEmbedding\n\n- [sentence-transformers/all-MiniLM-L6-v2](#sentence-transformersall-MiniLM-L6-v2)\n- [sentence-transformers/multi-qa-MiniLM-L6-cos-v1](#sentence-transformersmulti-qa-MiniLM-L6-cos-v1)\n- [sentence-transformers/all-mpnet-base-v2](#sentence-transformersall-mpnet-base-v2)\n- [sentence-transformers/paraphrase-MiniLM-L6-v2](#sentence-transformersparaphrase-minilm-l6-v2)\n- [mixedbread-ai/mxbai-embed-large-v1](#mixedbread-aimxbai-embed-large-v1)\n- [Supabase/gte-small](#supabasegte-small)\n- [intfloat/e5-base-v2](#intfloate5-base-v2)\n- [nomic-ai/nomic-embed-text-v1](#nomic-ainomic-embed-text-v1)\n- [BAAI/bge-base-en-v1.5](#baaibge-base-en-v15)\n- [jinaai/jina-embeddings-v2-base-en](#jinaaijina-embeddings-v2-base-en)\n- [Snowflake/snowflake-arctic-embed-m-v1.5](#snowflakesnowflake-arctic-embed-m-v15)\n\nReranking\n\n- [mixedbread-ai/mxbai-rerank-base-v1](#mixedbread-aimxbai-rerank-base-v1)\n- [jinaai/jina-reranker-v1-turbo-en](#jinaaijina-reranker-v1-turbo-en)\n- [BAAI/bge-reranker-base](#baaibge-reranker-base)\n- [Xenova/ms-marco-MiniLM-L-6-v2](#xenovams-marco-minilm-l-6-v2)\n\n### sentence-transformers/all-MiniLM-L6-v2\n\n[Docs](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)\n\n```ruby\nsentences = [\"This is an example sentence\", \"Each sentence is converted\"]\n\nmodel = Informers.pipeline(\"embedding\", \"sentence-transformers/all-MiniLM-L6-v2\")\nembeddings = model.(sentences)\n```\n\n### sentence-transformers/multi-qa-MiniLM-L6-cos-v1\n\n[Docs](https://huggingface.co/Xenova/multi-qa-MiniLM-L6-cos-v1)\n\n```ruby\nquery = \"How many people live in London?\"\ndocs = [\"Around 9 Million people live in London\", \"London is known for its financial district\"]\n\nmodel = Informers.pipeline(\"embedding\", \"sentence-transformers/multi-qa-MiniLM-L6-cos-v1\")\nquery_embedding = model.(query)\ndoc_embeddings = model.(docs)\nscores = doc_embeddings.map { |e| e.zip(query_embedding).sum { |d, q| d * q } }\ndoc_score_pairs = docs.zip(scores).sort_by { |d, s| -s }\n```\n\n### sentence-transformers/all-mpnet-base-v2\n\n[Docs](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)\n\n```ruby\nsentences = [\"This is an example sentence\", \"Each sentence is converted\"]\n\nmodel = Informers.pipeline(\"embedding\", \"sentence-transformers/all-mpnet-base-v2\")\nembeddings = model.(sentences)\n```\n\n### sentence-transformers/paraphrase-MiniLM-L6-v2\n\n[Docs](https://huggingface.co/sentence-transformers/paraphrase-MiniLM-L6-v2)\n\n```ruby\nsentences = [\"This is an example sentence\", \"Each sentence is converted\"]\n\nmodel = Informers.pipeline(\"embedding\", \"sentence-transformers/paraphrase-MiniLM-L6-v2\")\nembeddings = model.(sentences, normalize: false)\n```\n\n### mixedbread-ai/mxbai-embed-large-v1\n\n[Docs](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1)\n\n```ruby\nquery_prefix = \"Represent this sentence for searching relevant passages: \"\n\ninput = [\n  \"The dog is barking\",\n  \"The cat is purring\",\n  query_prefix + \"puppy\"\n]\n\nmodel = Informers.pipeline(\"embedding\", \"mixedbread-ai/mxbai-embed-large-v1\")\nembeddings = model.(input)\n```\n\n### Supabase/gte-small\n\n[Docs](https://huggingface.co/Supabase/gte-small)\n\n```ruby\nsentences = [\"That is a happy person\", \"That is a very happy person\"]\n\nmodel = Informers.pipeline(\"embedding\", \"Supabase/gte-small\")\nembeddings = model.(sentences)\n```\n\n### intfloat/e5-base-v2\n\n[Docs](https://huggingface.co/intfloat/e5-base-v2)\n\n```ruby\ndoc_prefix = \"passage: \"\nquery_prefix = \"query: \"\n\ninput = [\n  doc_prefix + \"Ruby is a programming language created by Matz\",\n  query_prefix + \"Ruby creator\"\n]\n\nmodel = Informers.pipeline(\"embedding\", \"intfloat/e5-base-v2\")\nembeddings = model.(input)\n```\n\n### nomic-ai/nomic-embed-text-v1\n\n[Docs](https://huggingface.co/nomic-ai/nomic-embed-text-v1)\n\n```ruby\ndoc_prefix = \"search_document: \"\nquery_prefix = \"search_query: \"\n\ninput = [\n  doc_prefix + \"The dog is barking\",\n  doc_prefix + \"The cat is purring\",\n  query_prefix + \"puppy\"\n]\n\nmodel = Informers.pipeline(\"embedding\", \"nomic-ai/nomic-embed-text-v1\")\nembeddings = model.(input)\n```\n\n### BAAI/bge-base-en-v1.5\n\n[Docs](https://huggingface.co/BAAI/bge-base-en-v1.5)\n\n```ruby\nquery_prefix = \"Represent this sentence for searching relevant passages: \"\n\ninput = [\n  \"The dog is barking\",\n  \"The cat is purring\",\n  query_prefix + \"puppy\"\n]\n\nmodel = Informers.pipeline(\"embedding\", \"BAAI/bge-base-en-v1.5\")\nembeddings = model.(input)\n```\n\n### jinaai/jina-embeddings-v2-base-en\n\n[Docs](https://huggingface.co/jinaai/jina-embeddings-v2-base-en)\n\n```ruby\nsentences = [\"How is the weather today?\", \"What is the current weather like today?\"]\n\nmodel = Informers.pipeline(\"embedding\", \"jinaai/jina-embeddings-v2-base-en\", model_file_name: \"../model\")\nembeddings = model.(sentences)\n```\n\n### Snowflake/snowflake-arctic-embed-m-v1.5\n\n[Docs](https://huggingface.co/Snowflake/snowflake-arctic-embed-m-v1.5)\n\n```ruby\nquery_prefix = \"Represent this sentence for searching relevant passages: \"\n\ninput = [\n  \"The dog is barking\",\n  \"The cat is purring\",\n  query_prefix + \"puppy\"\n]\n\nmodel = Informers.pipeline(\"embedding\", \"Snowflake/snowflake-arctic-embed-m-v1.5\")\nembeddings = model.(input, model_output: \"sentence_embedding\", pooling: \"none\")\n```\n\n### mixedbread-ai/mxbai-rerank-base-v1\n\n[Docs](https://huggingface.co/mixedbread-ai/mxbai-rerank-base-v1)\n\n```ruby\nquery = \"How many people live in London?\"\ndocs = [\"Around 9 Million people live in London\", \"London is known for its financial district\"]\n\nmodel = Informers.pipeline(\"reranking\", \"mixedbread-ai/mxbai-rerank-base-v1\")\nresult = model.(query, docs)\n```\n\n### jinaai/jina-reranker-v1-turbo-en\n\n[Docs](https://huggingface.co/jinaai/jina-reranker-v1-turbo-en)\n\n```ruby\nquery = \"How many people live in London?\"\ndocs = [\"Around 9 Million people live in London\", \"London is known for its financial district\"]\n\nmodel = Informers.pipeline(\"reranking\", \"jinaai/jina-reranker-v1-turbo-en\")\nresult = model.(query, docs)\n```\n\n### BAAI/bge-reranker-base\n\n[Docs](https://huggingface.co/BAAI/bge-reranker-base)\n\n```ruby\nquery = \"How many people live in London?\"\ndocs = [\"Around 9 Million people live in London\", \"London is known for its financial district\"]\n\nmodel = Informers.pipeline(\"reranking\", \"BAAI/bge-reranker-base\")\nresult = model.(query, docs)\n```\n\n### Xenova/ms-marco-MiniLM-L-6-v2\n\n[Docs](https://huggingface.co/Xenova/ms-marco-MiniLM-L-6-v2)\n\n```ruby\nquery = \"How many people live in London?\"\ndocs = [\"Around 9 Million people live in London\", \"London is known for its financial district\"]\n\nmodel = Informers.pipeline(\"reranking\", \"Xenova/ms-marco-MiniLM-L-6-v2\")\nresult = model.(query, docs)\n```\n\n### Other\n\nThe model must include a `.onnx` file ([example](https://huggingface.co/Xenova/all-MiniLM-L6-v2/tree/main/onnx)). If the file is not at `onnx/model.onnx`, use the `model_file_name` option to specify the location.\n\n## Pipelines\n\n- [Text](#text)\n- [Vision](#vision)\n- [Audio](#audio)\n- [Multimodel](#multimodal)\n\n### Text\n\nEmbedding\n\n```ruby\nembed = Informers.pipeline(\"embedding\")\nembed.(\"We are very happy to show you the 🤗 Transformers library.\")\n```\n\nReranking\n\n```ruby\nrerank = Informers.pipeline(\"reranking\")\nrerank.(\"Who created Ruby?\", [\"Matz created Ruby\", \"Another doc\"])\n```\n\nNamed-entity recognition\n\n```ruby\nner = Informers.pipeline(\"ner\")\nner.(\"Ruby is a programming language created by Matz\")\n```\n\nSentiment analysis\n\n```ruby\nclassifier = Informers.pipeline(\"sentiment-analysis\")\nclassifier.(\"We are very happy to show you the 🤗 Transformers library.\")\n```\n\nQuestion answering\n\n```ruby\nqa = Informers.pipeline(\"question-answering\")\nqa.(\"Who invented Ruby?\", \"Ruby is a programming language created by Matz\")\n```\n\nZero-shot classification\n\n```ruby\nclassifier = Informers.pipeline(\"zero-shot-classification\")\nclassifier.(\"text\", [\"label1\", \"label2\", \"label3\"])\n```\n\nText generation\n\n```ruby\ngenerator = Informers.pipeline(\"text-generation\")\ngenerator.(\"I enjoy walking with my cute dog,\")\n```\n\nText-to-text generation\n\n```ruby\ntext2text = Informers.pipeline(\"text2text-generation\")\ntext2text.(\"translate from English to French: I'm very happy\")\n```\n\nTranslation\n\n```ruby\ntranslator = Informers.pipeline(\"translation\", \"Xenova/nllb-200-distilled-600M\")\ntranslator.(\"जीवन एक चॉकलेट बॉक्स की तरह है।\", src_lang: \"hin_Deva\", tgt_lang: \"fra_Latn\")\n```\n\nSummarization\n\n```ruby\nsummarizer = Informers.pipeline(\"summarization\")\nsummarizer.(\"Many paragraphs of text\")\n```\n\nFill mask\n\n```ruby\nunmasker = Informers.pipeline(\"fill-mask\")\nunmasker.(\"Paris is the [MASK] of France.\")\n```\n\nFeature extraction\n\n```ruby\nextractor = Informers.pipeline(\"feature-extraction\")\nextractor.(\"We are very happy to show you the 🤗 Transformers library.\")\n```\n\n### Vision\n\nNote: [ruby-vips](https://github.com/libvips/ruby-vips) is required to load images\n\nImage classification\n\n```ruby\nclassifier = Informers.pipeline(\"image-classification\")\nclassifier.(\"image.jpg\")\n```\n\nZero-shot image classification\n\n```ruby\nclassifier = Informers.pipeline(\"zero-shot-image-classification\")\nclassifier.(\"image.jpg\", [\"label1\", \"label2\", \"label3\"])\n```\n\nImage segmentation\n\n```ruby\nsegmenter = Informers.pipeline(\"image-segmentation\")\nsegmenter.(\"image.jpg\")\n```\n\nObject detection\n\n```ruby\ndetector = Informers.pipeline(\"object-detection\")\ndetector.(\"image.jpg\")\n```\n\nZero-shot object detection\n\n```ruby\ndetector = Informers.pipeline(\"zero-shot-object-detection\")\ndetector.(\"image.jpg\", [\"label1\", \"label2\", \"label3\"])\n```\n\nDepth estimation\n\n```ruby\nestimator = Informers.pipeline(\"depth-estimation\")\nestimator.(\"image.jpg\")\n```\n\nImage-to-image\n\n```ruby\nupscaler = Informers.pipeline(\"image-to-image\")\nupscaler.(\"image.jpg\")\n```\n\nImage feature extraction\n\n```ruby\nextractor = Informers.pipeline(\"image-feature-extraction\")\nextractor.(\"image.jpg\")\n```\n\n### Audio\n\nNote: [ffmpeg](https://www.ffmpeg.org/) is required to load audio files\n\nAudio classification\n\n```ruby\nclassifier = Informers.pipeline(\"audio-classification\")\nclassifier.(\"audio.wav\")\n```\n\n### Multimodal\n\nImage captioning\n\n```ruby\ncaptioner = Informers.pipeline(\"image-to-text\")\ncaptioner.(\"image.jpg\")\n```\n\nDocument question answering\n\n```ruby\nqa = Informers.pipeline(\"document-question-answering\")\nqa.(\"image.jpg\", \"What is the invoice number?\")\n```\n\n## Reference\n\nSpecify a variant of the model if available (`fp32`, `fp16`, `int8`, `uint8`, `q8`, `q4`, `q4f16`, or `bnb4`)\n\n```ruby\nInformers.pipeline(\"embedding\", \"Xenova/all-MiniLM-L6-v2\", dtype: \"fp16\")\n```\n\nSpecify a device (`cpu`, `cuda`, or `coreml`)\n\n```ruby\nInformers.pipeline(\"embedding\", device: \"cuda\")\n```\n\nNote: Follow [these instructions](https://github.com/ankane/onnxruntime-ruby?tab=readme-ov-file#gpu-support) for `cuda`\n\nSpecify ONNX Runtime [session options](https://github.com/ankane/onnxruntime-ruby?tab=readme-ov-file#session-options)\n\n```ruby\nInformers.pipeline(\"embedding\", session_options: {log_severity_level: 2})\n```\n\n## Credits\n\nThis library was ported from [Transformers.js](https://github.com/huggingface/transformers.js) and is available under the same license.\n\n## Upgrading\n\n### 1.0\n\nTask classes have been replaced with the `pipeline` method.\n\n```ruby\n# before\nmodel = Informers::SentimentAnalysis.new(\"sentiment-analysis.onnx\")\nmodel.predict(\"This is super cool\")\n\n# after\nmodel = Informers.pipeline(\"sentiment-analysis\")\nmodel.(\"This is super cool\")\n```\n\n## History\n\nView the [changelog](https://github.com/ankane/informers/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/informers/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/informers/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone https://github.com/ankane/informers.git\ncd informers\nbundle install\nbundle exec rake download:files\nbundle exec rake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Finformers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Finformers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Finformers/lists"}