Quick Start
From zero to running, quickly load and test Tencent Youtu's Youtu-Embedding model locally.
1. System and Environment Requirements
| Item | Requirement |
|---|---|
| Python | 3.10 and above |
| Operating System | macOS or Linux |
| Memory | Recommended 16GB or more |
| Disk Space | Model size approximately 4–8GB |
2. Create and Activate Virtual Environment
It's recommended to create a separate Python virtual environment for this project to maintain clean dependencies.
3. Install Dependencies
Note: huggingface_hub is used to download models from Hugging Face.
4. Download Model
There are two ways to obtain the model:
4.1 Download Model Using Command Line
After download completes, the model will be saved in the ./youtu-model folder in the current directory.
4.2 Clone Model from Repository
You can also manually clone the model repository to pull the Embedding model into your local project.
5. Run Test Scripts
This section provides complete example scripts demonstrating how to load the model using Transformers, compute text embeddings, and output similarity matrices.
5.1 Automatically Pull Model Files and Test
Find and run the test script file test_transformers_online_cuda.py in the project root directory. It will automatically pull the model to local and process input text for vectorization:
Note: This test script requires CUDA environment and good network connectivity.
To run in macOS environment, find and run the test_transformers_online_macos.py test script in the code project:
After successful execution, the terminal will output vector scores for different results related to the question. Higher scores indicate greater relevance between the answer and the question.
5.2 Test Using Local Model
This step follows the previous section (4.2: Clone Model from Repository). Find and run the test_transformers_local.py test script in the project:
Run the script:
The following result in the terminal indicates successful local model invocation:
From the results, we can see that answers related to current weather have higher scores and are ranked first.
6. Summary
Through the above steps, you can quickly complete locally:
- Environment configuration
- Model download or reference
- Transformers environment initialization
- Output text embeddings and similarity results
7. Related Scripts
Some scripts are already available in the code repository.
Related Script Files:
test_transformers_online_cuda.py- CUDA environment test scripttest_transformers_online_macos.py- macOS environment test scripttest_transformers_local.py- Local model test scriptusage/infer_llm_embedding.py- Wrapper class usage exampletest/test_local_file_embeddings.py- Thousand-character Chinese text test case