This project demonstrates how to use Testcontainers for Golang to create a seamless development environment for building Generative AI applications.
01-hello-world
: Contains a simple example of using a language model to generate text.02-streaming
: Contains an example of using a language model to generate text in streaming mode.03-chat
: Contains an example of using a language model to generate text in a chat application.04-vision-model
: Contains an example of using a vision model to generate text from images.05-augmented-generation
: Contains an example of augmenting the prompt with additional information to generate more accurate text.06-embeddings
: Contains an example of generating embeddings from text and calculating similarity between them.07-rag
: Contains an example of applying RAG (Retrieval-Augmented Generation) to generate better responses.08-testing
: Contains an example with the evolution of testing our Generative AI applications, from an old school approach to a more modern one using Evaluator Agents.09-huggingface
: Contains an example of using a HuggingFace model with Ollama.10-functions
: Contains an example of using functions in a language model.
- Go 1.23 or higher
- Docker
- Clone the repository:
git clone https://github.com/mdelapenya/generative-ai-with-testcontainers.git cd generative-ai-with-testcontainers
To run the examples, navigate to the desired directory and run the go run .
command. For example, to run the 1-hello-world
example:
cd 1-hello-world
go run .
All the Docker images used in these example projects are available on Docker Hub under the https://hub.docker.com/u/mdelapenya repository. They have been built using an automated process in GitHub Actions, and you can find the source code in the following Github repository: https://github.com/mdelapenya/dockerize-ollama-models.
Each image basically starts from a base Ollama image, and then pulls the required models to run the examples. As a consequence, they are ready to be used in the examples without any additional setup, for you to just pull the given image and run it.
The images used in the examples are described below, grouped by model type. You can pull them using the pull-images.sh
script.
The Llama 3.2 collection of multilingual large language models (LLMs) is a collection of pretrained and instruction-tuned generative models in 1B and 3B sizes (text in/text out). The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks. They outperform many of the available open source and closed chat models on common industry benchmarks.
mdelapenya/llama3.2:0.5.4-1b
mdelapenya/llama3.2:0.5.4-3b
Qwen2 is a language model series including decoder language models of different model sizes. For each size, we release the base language model and the aligned chat model. It is based on the Transformer architecture with SwiGLU activation, attention QKV bias, group query attention, etc. Additionally, we have an improved tokenizer adaptive to multiple natural languages and codes.
mdelapenya/qwen2:0.5.4-0.5b
Moondream is a small vision language model designed to run efficiently on edge devices.
mdelapenya/moondream:0.5.4-1.8b
This model maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
mdelapenya/all-minilm:0.5.4-22m