This project demonstrates how to use the different LLMs for text generation using the @xenova/transformers
library or the @huggingface/transformers
library.
- Node.js (version 20 or higher recommended)
- npm (Node Package Manager)
-
Clone this repository or create a new directory for your project.
-
Navigate to the project directory in your terminal.
-
Install the required dependency:
npm install @xenova/transformers @huggingface/transformers
- Run the script using Node.js:
For example, to run example1.js
:
node example1.js
- The script will generate text based on the input prompt and display the output in the console.
- You can modify the
text
variable or other input parameters to change the input prompt. - Adjust the
max_new_tokens
andtemperature
parameters in thegenerator
function call to control the length and creativity of the generated text.
- The first time you run the script, it may take some time to download the model. Subsequent runs will be faster.
- Make sure you have a stable internet connection for the initial model download.
- GPU is recommended for better performance.
If you encounter any issues, please ensure that:
- You have the latest version of Node.js installed.
- All dependencies are correctly installed.
- You have sufficient disk space for the model download.