Skip to main content
LazyLLM is an open-source low-code large-model application development tool developed by SenseTime’s LazyAGI team. It provides one-stop tooling—from application building, data preparation, model deployment, fine-tuning to evaluation—so you can rapidly build AI applications at very low cost and continuously iterate to improve results.

API Signup & Environment Setup

1. Create an account

2. Environment setup

See docs: Quick Start – LazyLLM

API Usage Test

###0. Set Environment Variables You can use the following command to set the corresponding environment variable, or explicitly pass it in code:

1. Implement chat and image recognition

Text Q&A demo

After filling in the api_key, run the code below to quickly call the model and generate a Q&A-style front-end interface:
We ask “What is LazyLLM?”, and the result is as follows:

Multimodal Q&A demo

Pass an image through the lazyllm_files parameter in the input and ask about the image content to achieve multimodal question answering.
Here we use this image to test multimodal Q&A:
Output in the command line:

2. Implement text-to-image and text-to-speech

Use OnlineMultiModalModulefor text-to-image and text-to-speech. After running, it will output the path of the generated files.
Run result:
The generated audio is as follows:

3. Knowledge-base Q&A in 10+ lines of code

Implement Embed and Rerank functions

Run the code below to perform vector embeddings with OnlineEmbeddingModule; settype='rerank'to call a reranking model.
The vectorized result is as follows:
The word similarity scores are as follows:

Knowledge-base import

We use Chinese classical texts as an example knowledge base. After downloading, place them in the database folder. Sample dataset download link: Sample Dataset Download
First define the embed model, then use LazyLLM’s Document component to create a document management module for importing the knowledge base.

Knowledge-base retrieval

Now that we have an external knowledge base, we can use the Retriever component in LazyLLM to retrieve the knowledge base and recall relevant content. Usage example:

Knowledge-base Q&A

Combining the above model, document management, and retrieval modules, we can build a complete dataflow using LazyLLM’s built-in Flow component. The full code is as follows:
You can see that the RAG component successfully retrieves content related to the “Way of Heaven” from the Tao Te Ching and other sources, and passes it to the LLM for answering.