Rag Deepseek R1:1.5b
A Game Recommender RAG with DeepSeek & Ollama
In this recipe, we are building a custom RAG application designed to provide recommendations for games.
We use games.csv from the Epic Games dataset made public here on Kaggle.
- LLM: We run the
deepseek-r1:1.5bmodel with Ollama - Embedding model: For this example, we use the the
text2vec_openaicomponent with Weaviate, using the defuaulttext-embedding-3-smallmodel.
Install Dependencies & Set API Keys
Run the Model
For this example, we're running the deepseek-r1:1.5b model locally with ollama. For more information on how to run this on your OS, check out the Ollama Docs.
For example, on Mac:
ollama run deepseek-r1:1.5b
Create & Populate Weaviate Collection
First, we have to create a Weaviate collection and add some data into it. To complete this section:
- Download the
games.csvfile from Kaggle - Use the following
docker-compose.ymland rundocker compose upto start Weaviate with thegenerative-ollamaandtext2vec-openaimodules enabled.
---
services:
weaviate_anon:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: cr.weaviate.io/semitechnologies/weaviate:1.28.4
ports:
- 8080:8080
- 50051:50051
restart: on-failure:0
environment:
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ENABLE_API_BASED_MODULES: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node1'
LOG_LEVEL: 'trace'
ENABLE_MODULES: "text2vec-openai,generative-ollama"
...
- Now, you can create a new collection called "Games" below
<weaviate.collections.collection.sync.Collection at 0x12999fd40>
- Finally, we can add some of the data from
games.csvto our collection.
915it [00:09, 96.86it/s]
Embedding Search
The code block below is returning 3 of the most relevant games to the query. But we are not yet doing RAG with a specific instruction over these retrieved games.
{'platforms': ['Windows'], 'description': "A dark fantasy roguelike where you play as the Devil! Lead famous evil geniuses through events and turn-based fights to spread terror and corruption, and use your evil powers to change the game's rules to your advantage.", 'price': 2499, 'release_date': datetime.datetime(2021, 9, 30, 8, 0, tzinfo=datetime.timezone.utc), 'name': 'Rogue Lords'}
{'platforms': ['Windows'], 'description': 'Smash, clobber and bash the murderous legends of Slavic mythology in this darkly funny action role-playing game that changes every time you play. Play as Ivan, a one-handed blacksmith with incredibly bad luck, who must take on the impossible tasks given to him by the tzar. All...', 'price': 2499, 'release_date': datetime.datetime(2019, 11, 12, 14, 0, tzinfo=datetime.timezone.utc), 'name': 'Yaga'}
{'platforms': ['Windows'], 'description': 'In a violent, medieval world, outplay rival gangs in intense PvPvE multiplayer heists. Moving in stealth to steal treasures unseen or dominating through loud and brutal combat, only the best will escape with hard-earned riches.', 'name': 'Hood: Outlaws & Legends', 'release_date': datetime.datetime(2021, 5, 10, 15, 0, tzinfo=datetime.timezone.utc), 'price': 1999}
Recommendation RAG
Finally, we can crate a recommend_game function which is able to do rag with a grouped_task instruction.
You can try changing this instruction to something else too!
Below, we create an application which provides recommendations based on the most relevant 5 games in the dataset based on the user query, as well as providing information on what openrating systems the games are available on 👇
This generated response uses deepseek-r1:1.5b, which provides the thought generated by the model between <think> </think> tags. I've set up this function to return both recommendation and thought. You can later print these out separately.
Here are several games that allow you to role-play as a magical creature: 1. **Mages of Mystralia** - **Platform:** Windows - Description: A fantasy RPG where you design your own spells in a world of magic, allowing creativity and flexibility. 2. **Geneforge 1 - Mutagen** - **Platforms:** Windows, Mac - Description: An open-ended RPG with mutant monsters, multiple skills, treasures, factions, and creation possibilities, offering unparalleled freedom and replayability. 3. **Beasts of Maravilla Island** - **Platform:** Windows - Description: A 3D adventure game where you role as a wildlife photographer exploring magical ecosystems, focusing on behavior learning for photography. 4. **Paper Beast** - **Platforms:** Windows (PC) - Description: An adventure game about disrupting wildlife balance with a focus on exotic creatures and mystery-solving. 5. **Black Book** - **Platform:** Windows - Description: A dark RPG based on Slavic myths, played as a young sorceress in a world of mythological creatures through card-based battles. Each game offers unique experiences suitable for role-playing as a magical creature.
<think> Okay, so I need to figure out some games that let me role-play as a magical creature. The user provided several options, each with a description and platform. Let me go through them one by one. First up is "Mages of Mystralia." From the description, it's a fantasy RPG where you design your own spells in a world of magic. That sounds perfect because it allows for a lot of creativity as a magical creature. The platform is Windows, so maybe the user can run it on their PC or any desktop system. Next is "Geneforge 1 - Mutagen." This seems like an open-ended RPG with mutant monsters and a battle mechanic. It's described as having countless skills, treasures, factions, and creation possibilities. Unmatched freedom and replayability make sense because it allows for various storylines. The platform here is Windows and Mac, so compatible options would be useful. Then there's "Beasts of Maravilla Island." As the name suggests, it's a 3D adventure game where you take on a wildlife photographer exploring ecosystems. It focuses on behavior learning and photography, which could be exciting for someone looking to role-play in nature. The platform is Windows, so that should be accessible. "Paper Beast" is another adventure game mentioned. It's about an unknown power disrupting wildlife balance, with players joining exotic creatures to solve mysteries. While it's PC-focused, maybe there are porting options available or different devices that can run it if the user has access to them. Lastly, "Black Book." This dark RPG is based on Slavic myths and played as a young sorceress. It involves card-based battles in a world with mythological creatures. The platform here is Windows, so maybe older hardware might be a bit limiting unless the user has an updated PC or a dedicated console. I should make sure each game is listed clearly with their platforms and any necessary details about how they work as magical creatures. Also, it's good to offer a couple of options if some aren't available. Maybe suggest cross-platform games or platforms that can be used for playing.