百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

informers

> 编程语言
开源

Ruby 的快速 Transformer 推理

616 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Ruby 的快速 Transformer 推理

Informers

:fire: Fast transformer inference for Ruby

For non-ONNX models, check out Transformers.rb :slightly_smiling_face:

Installation

Add this line to your application’s Gemfile:

ruby
gem "informers"

Getting Started

  • Models
  • Pipelines

Models

Embedding

  • sentence-transformers/all-MiniLM-L6-v2
  • sentence-transformers/multi-qa-MiniLM-L6-cos-v1
  • sentence-transformers/all-mpnet-base-v2
  • sentence-transformers/paraphrase-MiniLM-L6-v2
  • mixedbread-ai/mxbai-embed-large-v1
  • Supabase/gte-small
  • intfloat/e5-base-v2
  • nomic-ai/nomic-embed-text-v1
  • BAAI/bge-base-en-v1.5
  • jinaai/jina-embeddings-v2-base-en
  • Snowflake/snowflake-arctic-embed-m-v1.5

Reranking

  • mixedbread-ai/mxbai-rerank-base-v1
  • jinaai/jina-reranker-v1-turbo-en
  • BAAI/bge-reranker-base
  • Xenova/ms-marco-MiniLM-L-6-v2

sentence-transformers/all-MiniLM-L6-v2

Docs

ruby
sentences = ["This is an example sentence", "Each sentence is converted"]

model = Informers.pipeline("embedding", "sentence-transformers/all-MiniLM-L6-v2")
embeddings = model.(sentences)

sentence-transformers/multi-qa-MiniLM-L6-cos-v1

Docs

ruby
query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

model = Informers.pipeline("embedding", "sentence-transformers/multi-qa-MiniLM-L6-cos-v1")
query_embedding = model.(query)
doc_embeddings = model.(docs)
scores = doc_embeddings.map { |e| e.zip(query_embedding).sum { |d, q| d * q } }
doc_score_pairs = docs.zip(scores).sort_by { |d, s| -s }

sentence-transformers/all-mpnet-base-v2

Docs

ruby
sentences = ["This is an example sentence", "Each sentence is converted"]

model = Informers.pipeline("embedding", "sentence-transformers/all-mpnet-base-v2")
embeddings = model.(sentences)

sentence-transformers/paraphrase-MiniLM-L6-v2

Docs

ruby
sentences = ["This is an example sentence", "Each sentence is converted"]

model = Informers.pipeline("embedding", "sentence-transformers/paraphrase-MiniLM-L6-v2")
embeddings = model.(sentences, normalize: false)

mixedbread-ai/mxbai-embed-large-v1

Docs

ruby
query_prefix = "Represent this sentence for searching relevant passages: "

input = [
  "The dog is barking",
  "The cat is purring",
  query_prefix + "puppy"
]

model = Informers.pipeline("embedding", "mixedbread-ai/mxbai-embed-large-v1")
embeddings = model.(input)

Supabase/gte-small

Docs

ruby
sentences = ["That is a happy person", "That is a very happy person"]

model = Informers.pipeline("embedding", "Supabase/gte-small")
embeddings = model.(sentences)

intfloat/e5-base-v2

Docs

ruby
doc_prefix = "passage: "
query_prefix = "query: "

input = [
  doc_prefix + "Ruby is a programming language created by Matz",
  query_prefix + "Ruby creator"
]

model = Informers.pipeline("embedding", "intfloat/e5-base-v2")
embeddings = model.(input)

nomic-ai/nomic-embed-text-v1

Docs

ruby
doc_prefix = "search_document: "
query_prefix = "search_query: "

input = [
  doc_prefix + "The dog is barking",
  doc_prefix + "The cat is purring",
  query_prefix + "puppy"
]

model = Informers.pipeline("embedding", "nomic-ai/nomic-embed-text-v1")
embeddings = model.(input)

BAAI/bge-base-en-v1.5

Docs

ruby
query_prefix = "Represent this sentence for searching relevant passages: "

input = [
  "The dog is barking",
  "The cat is purring",
  query_prefix + "puppy"
]

model = Informers.pipeline("embedding", "BAAI/bge-base-en-v1.5")
embeddings = model.(input)

jinaai/jina-embeddings-v2-base-en

Docs

ruby
sentences = ["How is the weather today?", "What is the current weather like today?"]

model = Informers.pipeline("embedding", "jinaai/jina-embeddings-v2-base-en", model_file_name: "../model")
embeddings = model.(sentences)

Snowflake/snowflake-arctic-embed-m-v1.5

Docs

ruby
query_prefix = "Represent this sentence for searching relevant passages: "

input = [
  "The dog is barking",
  "The cat is purring",
  query_prefix + "puppy"
]

model = Informers.pipeline("embedding", "Snowflake/snowflake-arctic-embed-m-v1.5")
embeddings = model.(input, model_output: "sentence_embedding", pooling: "none")

mixedbread-ai/mxbai-rerank-base-v1

Docs

ruby
query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

model = Informers.pipeline("reranking", "mixedbread-ai/mxbai-rerank-base-v1")
result = model.(query, docs)

jinaai/jina-reranker-v1-turbo-en

Docs

ruby
query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

model = Informers.pipeline("reranking", "jinaai/jina-reranker-v1-turbo-en")
result = model.(query, docs)

BAAI/bge-reranker-base

Docs

ruby
query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

model = Informers.pipeline("reranking", "BAAI/bge-reranker-base")
result = model.(query, docs)

Xenova/ms-marco-MiniLM-L-6-v2

Docs

ruby
query = "How many people live in London?"
docs = ["Around 9 Million people live in London", "London is known for its financial district"]

model = Informers.pipeline("reranking", "Xenova/ms-marco-MiniLM-L-6-v2")
result = model.(query, docs)

Other

The model must include a .onnx file (example). If the file is not at onnx/model.onnx, use the model_file_name option to specify the location.

Pipelines

  • Text
  • Vision
  • Audio
  • Multimodel

Text

Embedding

ruby
embed = Informers.pipeline("embedding")
embed.("We are very happy to show you the  Transformers library.")

Reranking

ruby
rerank = Informers.pipeline("reranking")
rerank.("Who created Ruby?", ["Matz created Ruby", "Another doc"])

Named-entity recognition

ruby
ner = Informers.pipeline("ner")
ner.("Ruby is a programming language created by Matz")

Sentiment analysis

ruby
classifier = Informers.pipeline("sentiment-analysis")
classifier.("We are very happy to show you the  Transformers library.")

Question answering

ruby
qa = Informers.pipeline("question-answering")
qa.("Who invented Ruby?", "Ruby is a programming language created by Matz")

Zero-shot classification

ruby
classifier = Informers.pipeline("zero-shot-classification")
classifier.("text", ["label1", "label2", "label3"])

Text generation

ruby
generator = Informers.pipeline("text-generation")
generator.("I enjoy walking with my cute dog,")

Text-to-text generation

ruby
text2text = Informers.pipeline("text2text-generation")
text2text.("translate from English to French: I'm very happy")

Translation

ruby
translator = Informers.pipeline("translation", "Xenova/nllb-200-distilled-600M")
translator.("जीवन एक चॉकलेट बॉक्स की तरह है।", src_lang: "hin_Deva", tgt_lang: "fra_Latn")

Summarization

ruby
summarizer = Informers.pipeline("summarization")
summarizer.("Many paragraphs of text")

Fill mask

ruby
unmasker = Informers.pipeline("fill-mask")
unmasker.("Paris is the [MASK] of France.")

Feature extraction

ruby
extractor = Informers.pipeline("feature-extraction")
extractor.("We are very happy to show you the  Transformers library.")

Vision

Note: ruby-vips is required to load images

Image classification

ruby
classifier = Informers.pipeline("image-classification")
classifier.("image.jpg")

Zero-shot image classification

ruby
classifier = Informers.pipeline("zero-shot-image-classification")
classifier.("image.jpg", ["label1", "label2", "label3"])

Image segmentation

ruby
segmenter = Informers.pipeline("image-segmentation")
segmenter.("image.jpg")

Object detection

ruby
detector = Informers.pipeline("object-detection")
detector.("image.jpg")

Zero-shot object detection

ruby
detector = Informers.pipeline("zero-shot-object-detection")
detector.("image.jpg", ["label1", "label2", "label3"])

Depth estimation

ruby
estimator = Informers.pipeline("depth-estimation")
estimator.("image.jpg")

Image-to-image

ruby
upscaler = Informers.pipeline("image-to-image")
upscaler.("image.jpg")

Image feature extraction

ruby
extractor = Informers.pipeline("image-feature-extraction")
extractor.("image.jpg")

Audio

Note: ffmpeg is required to load audio files

Audio classification

ruby
classifier = Informers.pipeline("audio-classification")
classifier.("audio.wav")

Multimodal

Image captioning

ruby
captioner = Informers.pipeline("image-to-text")
captioner.("image.jpg")

Document question answering

ruby
qa = Informers.pipeline("document-question-answering")
qa.("image.jpg", "What is the invoice number?")

Reference

Specify a variant of the model if available (fp32, fp16, int8, uint8, q8, q4, q4f16, or bnb4)

ruby
Informers.pipeline("embedding", "Xenova/all-MiniLM-L6-v2", dtype: "fp16")

Specify a device (cpu, cuda, or coreml)

ruby
Informers.pipeline("embedding", device: "cuda")

Note: Follow these instructions for cuda

Specify ONNX Runtime session options

ruby
Informers.pipeline("embedding", session_options: {log_severity_level: 2})

Credits

This library was ported from Transformers.js and is available under the same license.

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

  • Report bugs
  • Fix bugs and submit pull requests
  • Write, clarify, or fix documentation
  • Suggest or add new features

To get started with development:

bash
git clone https://github.com/ankane/informers.git
cd informers
bundle install
bundle exec rake download:files
bundle exec rake test

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubynamed-entity-recognitionquestion-answeringsentiment-analysis

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言