releases.shpreview

2.13.1

$npx -y @buildinternet/releases show rel_f6Vt5oNkwZRbkpyxeNf20

What's new?

  • Improve typing of pipeline function in https://github.com/xenova/transformers.js/pull/485. Thanks to @wesbos for the suggestion!

    typing-demo

    This also means when you hover over the class name, you'll get example code to help you out. typing-demo2

  • Add phi-1_5 model in https://github.com/xenova/transformers.js/pull/493.

    <details> <summary>See example code</summary>
    import { pipeline } from '@xenova/transformers';
    
    // Create a text-generation pipeline
    const generator = await pipeline('text-generation', 'Xenova/phi-1_5_dev');
    
    // Construct prompt
    const prompt = `\`\`\`py
    import math
    def print_prime(n):
        """
        Print all primes between 1 and n
        """`;
    
    // Generate text
    const result = await generator(prompt, {
      max_new_tokens: 100,
    });
    console.log(result[0].generated_text);

    Results in:

    import math
    def print_prime(n):
        """
        Print all primes between 1 and n
        """
        primes = []
        for num in range(2, n+1):
            is_prime = True
            for i in range(2, int(math.sqrt(num))+1):
                if num % i == 0:
                    is_prime = False
                    break
            if is_prime:
                primes.append(num)
        print(primes)
    
    print_prime(20)
    

    Running the code produces the correct result:

    [2, 3, 5, 7, 11, 13, 17, 19]
    
    </details>

Full Changelog: https://github.com/xenova/transformers.js/compare/2.13.0...2.13.1

Fetched April 7, 2026