README.md
November 24, 2025 · View on GitHub
Redis AI Java Resources
Setup | Running the Project | Notebooks | Project Structure | Implementation Details
Setup
This project uses Docker Compose to set up a complete environment for running Java-based AI applications with Redis. The environment includes:
- A Jupyter Notebook server with Java kernel support (For notebooks that based on Java)
- Redis Stack (includes Redis and RedisInsight)
- Pre-installed dependencies for AI/ML workloads
Prerequisites
- Docker and Docker Compose
- OpenAI API key (for notebooks that use OpenAI services)
Environment Configuration
- Create a
.envfile in the project root with your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
Running the Project
-
Clone the repository (if you haven't already):
git clone https://github.com/redis-developer/redis-ai-resources.git cd redis-ai-resources/java-resources -
Start the Docker containers:
docker-compose up -d -
Access the Jupyter environment:
-
Open your browser and navigate to http://localhost:8888
-
The token is usually shown in the docker-compose logs. You can view them with:
docker-compose logs jupyter
-
-
Access RedisInsight:
- Open your browser and navigate to http://localhost:8001
- Connect to Redis using the following details:
- Host: redis-java
- Port: 6379
- No password (unless configured)
-
When finished, stop the containers:
docker-compose down
Notebooks
| Notebook | Description |
|---|---|
| RAG/spring_ai_redis_rag.ipynb | Demonstrates building a RAG-based beer recommendation chatbot using Spring AI and Redis as the vector store |
| semantic-routing/1_semantic_classification.ipynb | Demonstrates how to perform text classification with vector search (RedisVL) instead of LLMs |
| semantic-routing/2_semantic_tool_calling.ipynb | Demonstrates how to perform tool selection with vector search (RedisVL) instead of LLMs |
| semantic-routing/3_semantic_guardrails.ipynb | Demonstrates how to implement guardrails with vector search (RedisVL) |
| semantic-caching/1_pre_generated_semantic_caching.ipynb | Demonstrates how to perform pre generated semantic caching with RedisVL |
| semantic-caching/2_semantic_caching_with_langcache.ipynb | Demonstrates how to perform pre generated semantic caching with LangCache |
Project Structure
notebooks/
├── .env # Environment variables (create this)
├── docker-compose.yml # Docker Compose configuration
├── jupyter/ # Jupyter configuration files
│ ├── Dockerfile # Dockerfile for Jupyter with Java kernel
│ ├── environment.yml # Conda environment specification
│ ├── install.py # JJava kernel installation script
│ ├── kernel.json # Kernel specification
│ └── java/ # Java dependencies and configuration
│ └── pom.xml # Maven project file with dependencies
└── resources/ # Data files for notebooks
└── beers.json.gz # Compressed beer dataset
Implementation Details
Java Jupyter Kernel
The project uses JJava, a Jupyter kernel for Java based on JShell. This allows for interactive Java development in Jupyter notebooks.
Key components:
- Java 21 for modern Java features
- Maven for dependency management
- JJava kernel for Jupyter integration
Spring AI Integration
The Spring AI notebooks showcase how to use Spring's AI capabilities with Redis:
- Spring AI: Framework for building AI-powered applications
- Redis Vector Store: Used for storing and querying vector embeddings
- Transformer Models: For generating embeddings locally
- RAG Pattern: Demonstrates the Retrieval Augmented Generation pattern
Docker Configuration
The Docker setup includes:
-
Jupyter Container:
- Based on minimal Jupyter notebook image
- Adds Java 21, Maven, and the JJava kernel
- Includes Python environment with PyTorch and other ML libraries
-
Redis Container:
- Uses Redis Stack image with Vector Search capabilities
- Persists data using Docker volumes
- Exposes Redis on port 6379 and RedisInsight on port 8001