Transformers-js-py

Latest version: v0.19.4

Safety actively analyzes 688053 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 14

2.4.1

What's new?
Minor bug fixes
* Fix padding and truncation of long sequences in certain pipelines by xenova in https://github.com/xenova/transformers.js/pull/190
* Object-detection pipeline improvements + better documentation by xenova in https://github.com/xenova/transformers.js/pull/189


**Full Changelog**: https://github.com/xenova/transformers.js/compare/2.4.0...2.4.1

2.4.0

What's new?

Word-level timestamps for Whisper automatic-speech-recognition 🤯

This release adds the ability to predict word-level timestamps for our whisper automatic-speech-recognition models by analyzing the cross-attentions and applying dynamic time warping. Our implementation is adapted from this [PR](https://github.com/huggingface/transformers/pull/23205), which added this functionality to the [🤗 transformers](https://github.com/huggingface/transformers) Python library.

**Example usage:** (see [docs](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.AutomaticSpeechRecognitionPipeline))

js
import { pipeline } from 'xenova/transformers';

let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en', {
revision: 'output_attentions',
});
let output = await transcriber(url, { return_timestamps: 'word' });
// {
// "text": " And so my fellow Americans ask not what your country can do for you ask what you can do for your country.",
// "chunks": [

2.3.1

What's new?
New models and tokenizers
- Models:
- `MobileViT` for image classification
- `Roberta` for token classification (thanks julien-c)
- `XLMRoberta` for masked language modelling, sequence classification, token classification, and question answering
- Tokenizers: `FalconTokenizer`, `GPTNeoXTokenizer`

Improved documentation
- Details on how to discover and share transformers.js models on the hub ([link](https://github.com/xenova/transformers.js#supported-tasksmodels))
- Example text-generation code ([link](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextGenerationPipeline))
- Example image-classification code ([link](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ImageClassificationPipeline))
Misc bug fixes
- Fix conversion to grayscale ([commit](https://github.com/xenova/transformers.js/commit/1914c0784d4491238e73da885231aa158b84f7f9))
- Aligned `.generate()` function output with original python implementation
- Fix issue with non-greedy samplers
- Use WASM SIMD on iOS != 16.4.x (thanks lsb)

New Contributors
* julien-c made their first contribution in https://github.com/xenova/transformers.js/pull/170
* lsb made their first contribution in https://github.com/xenova/transformers.js/pull/174

**Full Changelog**: https://github.com/xenova/transformers.js/compare/2.3.0...2.3.1

2.3.0

What's new?

Improved 🤗 Hub integration and model discoverability!

All Transformers.js-compatible models are now displayed with a super cool tag! To indicate your model is compatible with the library, simply add the "transformers.js" library tag in your README ([example](https://huggingface.co/Xenova/whisper-tiny/raw/main/README.md)).
![image](https://github.com/xenova/transformers.js/assets/26504141/9cc65e22-cdb4-400f-a589-863695d61842)


This also means you can now **search** for and **filter** these models by task!
![image](https://github.com/xenova/transformers.js/assets/26504141/ceadc074-a331-48a9-a9ee-a54bfcb31264)


For example,
- https://huggingface.co/models?library=transformers.js lists all Transformers.js models
- https://huggingface.co/models?library=transformers.js&pipeline_tag=feature-extraction lists all models which can be used in the `feature-extraction` pipeline!

And lastly, clicking the "Use in Transformers.js" button will show some sample code for how to use the model!
![image](https://github.com/xenova/transformers.js/assets/26504141/512e7874-f7f2-41a9-af34-d486adadcb3c)


Chroma 🤝 Transformers.js

You can now use all Transformers.js-compatible feature-extraction models for embeddings computation directly in Chroma! For example:
js
const {ChromaClient, TransformersEmbeddingFunction} = require('chromadb');
const client = new ChromaClient();

// Create the embedder. In this case, I just use the defaults, but you can change the model,
// quantization, revision, or add a progress callback, if desired.
const embedder = new TransformersEmbeddingFunction({ /* Configuration goes here */ });

const main = async () => {
// Empties and completely resets the database.
await client.reset()

// Create the collection
const collection = await client.createCollection({name: "my_collection", embeddingFunction: embedder})

// Add some data to the collection
await collection.add({
ids: ["id1", "id2", "id3"],
metadatas: [{"source": "my_source"}, {"source": "my_source"}, {"source": "my_source"}],
documents: ["I love walking my dog", "This is another document", "This is a legal document"],
})

// Query the collection
const results = await collection.query({
nResults: 2,
queryTexts: ["This is a query document"]
})
console.log(results)
// {
// ids: [ [ 'id2', 'id3' ] ],
// embeddings: null,
// documents: [ [ 'This is another document', 'This is a legal document' ] ],
// metadatas: [ [ [Object], [Object] ] ],
// distances: [ [ 1.0109775066375732, 1.0756263732910156 ] ]
// }
}

main();


Other links:
- [List of compatible models](https://huggingface.co/models?library=transformers.js&pipeline_tag=feature-extraction)
- [PR](https://github.com/chroma-core/chroma/pull/664)


Better alignment with python library for calling decoder-only models

You can now call decoder-only models loaded via `AutoModel.from_pretrained(...)`:
js
import { AutoModel, AutoTokenizer } from 'xenova/transformers';

// Choose model to use
let model_id = "Xenova/gpt2";

// Load model and tokenizer
let tokenizer = await AutoTokenizer.from_pretrained(model_id);
let model = await AutoModel.from_pretrained(model_id);

// Tokenize text and call
let model_inputs = await tokenizer('Once upon a time');
let output = await model(model_inputs);

console.log(output);
// {
// logits: Tensor {
// dims: [ 1, 4, 50257 ],
// type: 'float32',
// data: Float32Array(201028) [

2.2.0

What's new?
[Multilingual speech recognition and translation w/ Whisper](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.AutomaticSpeechRecognitionPipeline)
You can now transcribe and translate speech for over 100 different languages, directly in your browser, with Whisper! Play around with our demo application [here](https://huggingface.co/spaces/Xenova/whisper-web).

**Example**: Transcribe English.
js
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
let output = await transcriber(url);
// { text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country." }


**Example**: Transcribe English w/ timestamps.
js
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny.en');
let output = await transcriber(url, { return_timestamps: true });
// {
// text: " And so my fellow Americans ask not what your country can do for you, ask what you can do for your country."
// chunks: [
// { timestamp: [0, 8], text: " And so my fellow Americans ask not what your country can do for you" }
// { timestamp: [8, 11], text: " ask what you can do for your country." }
// ]
// }


**Example**: Transcribe French.
js
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/french-audio.mp3';
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-small');
let output = await transcriber(url, { language: 'french', task: 'transcribe' });
// { text: " J'adore, j'aime, je n'aime pas, je déteste." }


**Example**: Translate French to English.
js
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/french-audio.mp3';
let transcriber = await pipeline('automatic-speech-recognition', 'Xenova/whisper-small');
let output = await transcriber(url, { language: 'french', task: 'translate' });
// { text: " I love, I like, I don't like, I hate." }



Misc
- Aligned `.generate()` function with original python implementation
- Minor improvements to documentation (+ some examples). More to come in the future.


**Full Changelog**: https://github.com/xenova/transformers.js/compare/2.1.1...2.2.0

2.1.1

Minor patch for [v2.1.0](https://github.com/xenova/transformers.js/releases/tag/2.1.0) to fix an issue with browser caching.

Page 8 of 14

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.