mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-28 07:28:30 +02:00
add scaleway and ovhcloud tutorials
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
draft: false
|
||||
draft: true
|
||||
title: "Oracle Cloud Infrastructure and Qdrant Hybrid Cloud"
|
||||
short_description: "A winning combination for enterprise-scale RAG consists of a strong framework and a scalable database."
|
||||
description: "A winning combination for enterprise-scale RAG consists of a strong framework and a scalable database."
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
draft: false
|
||||
draft: true
|
||||
title: "Red Hat OpenShift and Qdrant Hybrid Cloud"
|
||||
short_description: "A winning combination for enterprise-scale RAG consists of a strong framework and a scalable database."
|
||||
description: "A winning combination for enterprise-scale RAG consists of a strong framework and a scalable database."
|
||||
|
||||
@@ -9,7 +9,7 @@ weight: 10
|
||||
## Product Release: Announcing Qdrant Hybrid Cloud!
|
||||
***<p style="text-align: center;">Now you can attach your own infrastructure to [Qdrant Cloud](/documentation/cloud/)!</p>***
|
||||
|
||||
[](https://qdrant.to/cloud)
|
||||
[](https://qdrant.to/cloud)
|
||||
Build the best private environment that suits your needs. Use our Cloud to manage your clusters, but continue to run them within your own private infrastructure. **Get the most out of Qdrant: scalability, flexibility and data sovereignty!**
|
||||
|
||||
## First-Time Users:
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
---
|
||||
title: Build a RAG-Based Chatbot on Scaleway
|
||||
title: Blog-Reading Web Scraper Chatbot on Scaleway
|
||||
weight: 35
|
||||
aliases:
|
||||
- /documentation/tutorials/rag-chatbot-scaleway/
|
||||
---
|
||||
|
||||
# Build a RAG-Based Chatbot on Scaleway
|
||||
# Blog-Reading Web Scraper Chatbot on Scaleway
|
||||
|
||||
| Time: 90 min | Level: Advanced | | |
|
||||
| Time: 90 min | Level: Advanced |[GitHub](https://github.com/qdrant/examples/blob/master/langchain-lcel-rag/Langchain-LCEL-RAG-Demo.ipynb)| |
|
||||
|--------------|-----------------|--|----|
|
||||
|
||||
## Langchain x Qdrant: RAG Demo with Web Scraping
|
||||
In this tutorial, you will build a RAG system that combines web scraping with the capabilities of semantic search. RAG enhances the generation of answers by retrieving relevant documents to aid the question-answering process. This setup showcases the integration of advanced search and AI language processing to improve information retrieval and generation tasks.
|
||||
|
||||
This section introduces the demonstration of building a Retrieval-Augmented Generation (RAG) model that combines web scraping with the capabilities of Langchain and Qdrant. The RAG model enhances the generation of answers by first retrieving relevant documents. Qdrant serves as the vector search engine for retrieval, while GPT-3.5, developed by OpenAI, is utilized as the generator for producing answers. This setup showcases the integration of advanced search and AI language processing to improve information retrieval and generation tasks.
|
||||
A notebook for this tutorial is available on [GitHub](https://github.com/qdrant/examples/blob/master/langchain-lcel-rag/Langchain-LCEL-RAG-Demo.ipynb).
|
||||
|
||||
**Data Privacy and Sovereignty:** RAG applications often rely on sensitive or proprietary internal data. Running the entire stack within your own environment becomes crucial for maintaining control over this data. Qdrant Hybrid Cloud deployed on [Scaleway](https://www.scaleway.com/) addresses this need perfectly, offering a secure, scalable platform that still leverages the full potential of RAG. Scaleway offers serverless [Functions](https://www.scaleway.com/en/serverless-functions/) and serverless [Jobs](https://www.scaleway.com/en/serverless-jobs/), both of which are ideal for embedding creation in large-scale RAG cases.
|
||||
|
||||
## Components
|
||||
|
||||
- **Cloud Host:** [Scaleway on managed Kubernetes](https://www.scaleway.com/en/kubernetes-kapsule/) for compatibility with Qdrant Hybrid Cloud.
|
||||
- **Vector Database:** Qdrant Hybrid Cloud as the vector search engine for retrieval.
|
||||
- **LLM:** GPT-3.5, developed by OpenAI is utilized as the generator for producing answers.
|
||||
- **Framework:** [LangChain](https://www.langchain.com/) for extensive RAG capabilities.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -34,13 +41,13 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
||||
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
||||
```
|
||||
|
||||
### Setting Up the OpenAI API Key
|
||||
Set up the OpenAI API key:
|
||||
|
||||
```python
|
||||
os.environ["OPENAI_API_KEY"] = getpass.getpass()
|
||||
```
|
||||
|
||||
### Initializing the Language Model
|
||||
Initialize the language model:
|
||||
|
||||
```python
|
||||
llm = ChatOpenAI(model="gpt-3.5-turbo-0125")
|
||||
@@ -48,7 +55,7 @@ llm = ChatOpenAI(model="gpt-3.5-turbo-0125")
|
||||
|
||||
It is here that we configure both the Embeddings and LLM. You can replace this with your own models using Ollama or other services. Scaleway has some great [GPU Instances](https://www.scaleway.com/en/gpu-instances/) too - including H100 on the higher end, and soon L4 for everything small.
|
||||
|
||||
## Download and Index
|
||||
## Download and parse data
|
||||
|
||||
To begin working with blog post contents, the process involves loading and parsing the HTML content. This is achieved using `urllib` and `BeautifulSoup`, which are tools designed for such tasks. After the content is loaded and parsed, it is indexed using Qdrant, a powerful tool for managing and querying vector data. The code snippet demonstrates how to load, chunk, and index the contents of a blog post by specifying the URL of the blog and the specific HTML elements to parse. This step is crucial for preparing the data for further processing and analysis with Qdrant.
|
||||
|
||||
@@ -66,7 +73,7 @@ docs = loader.load()
|
||||
|
||||
```
|
||||
|
||||
### Chunking before Indexing
|
||||
### Chunking data
|
||||
|
||||
When dealing with large documents, such as a blog post exceeding 42,000 characters, it's crucial to manage the data efficiently for processing. Many models have a limited context window and struggle with long inputs, making it difficult to extract or find relevant information. To overcome this, the document is divided into smaller chunks. This approach enhances the model's ability to process and retrieve the most pertinent sections of the document effectively.
|
||||
|
||||
@@ -83,16 +90,17 @@ vectorstore = Qdrant.from_documents(
|
||||
)
|
||||
```
|
||||
|
||||
## Retrieve and Generate
|
||||
## Retrieve and generate content
|
||||
|
||||
In this section, the process of retrieving information and generating content using a vector store and a language model is outlined. The `vectorstore` is utilized as a retriever to fetch relevant documents based on vector similarity. The `hub.pull("rlm/rag-prompt")` function is used to pull a specific prompt from a repository, which is designed to work with retrieved documents and a question to generate a response.
|
||||
The `vectorstore` is used as a retriever to fetch relevant documents based on vector similarity. The `hub.pull("rlm/rag-prompt")` function is used to pull a specific prompt from a repository, which is designed to work with retrieved documents and a question to generate a response.
|
||||
|
||||
The `format_docs` function formats the retrieved documents into a single string, preparing them for further processing. This formatted string, along with a question, is passed through a chain of operations. Firstly, the context (formatted documents) and the question are processed by the retriever and the prompt. Then, the result is fed into a large language model (`llm`) for content generation. Finally, the output is parsed into a string format using `StrOutputParser()`.
|
||||
|
||||
This chain of operations demonstrates a sophisticated approach to information retrieval and content generation, leveraging both the semantic understanding capabilities of vector search and the generative prowess of large language models.
|
||||
|
||||
Now, retrieve and generate data using relevant snippets from the blogL
|
||||
|
||||
```python
|
||||
# Retrieve and generate using the relevant snippets of the blog.
|
||||
retriever = vectorstore.as_retriever()
|
||||
prompt = hub.pull("rlm/rag-prompt")
|
||||
|
||||
@@ -115,7 +123,15 @@ rag_chain = (
|
||||
rag_chain.invoke("What is Task Decomposition?")
|
||||
```
|
||||
|
||||
## Deploying Langchain Applications on Scaleway
|
||||
Scaleway has serverless [Functions](https://www.scaleway.com/en/serverless-functions/) and serverless [Jobs](https://www.scaleway.com/en/serverless-jobs/) -- ideal for embedding creation when doing a bulk operation.
|
||||
## Next steps:
|
||||
We built a solid foundation for a simple chatbot, but there is still a lot to do. If you want to make the
|
||||
system production-ready, you should consider implementing the mechanism into your existing stack. We recommend
|
||||
|
||||
Our vector database can easily be hosted on [Scaleway](https://www.scaleway.com/), our trusted [Qdrant Hybrid Cloud](/documentation/hybrid-cloud/) partner. This means that Qdrant can be run from your Scaleway region, but the database itself can still be managed from within Qdrant Cloud's interface. Both products have been tested for compatibility and scalability, and we recommend their [managed Kubernetes](https://www.scaleway.com/en/kubernetes-kapsule/) service.
|
||||
Their French deployment regions e.g. France are excellent for network latency and data sovereignty. For hosted GPUs, try [rendering with P100](https://www.scaleway.com/en/gpu-render-instances/).
|
||||
|
||||
If you have any questions, feel free to ask on our [Discord community](https://qdrant.to/discord).
|
||||
|
||||
|
||||
|
||||
|
||||
Their French deployment regions e.g. France are excellent for network latency and data sovereignty. Need a GPU? [Render with P100](https://www.scaleway.com/en/gpu-render-instances/) is there for you.
|
||||
@@ -1,51 +1,55 @@
|
||||
---
|
||||
title: Movie Recommendation System
|
||||
title: Movie Recommendation System on OVHcloud
|
||||
weight: 34
|
||||
aliases:
|
||||
- /documentation/tutorials/recommendation-system-ovhcloud/
|
||||
---
|
||||
|
||||
# Build a Movie Recommendation System
|
||||
# Movie Recommendation System on OVHcloud
|
||||
|
||||
| Time: 120 min | Level: Advanced | Output: [GitHub](https://github.com/infoslack/qdrant-example/blob/main/HC-demo/HC-OVH.ipynb) |
|
||||
| --- | ----------- | ----------- |----------- |
|
||||
|
||||
This notebook aims to create a recommendation system using the MovieLens dataset and Qdrant. Vector databases like Qdrant are crucial for storing high-dimensional data, such as user and item embeddings, enabling personalized recommendations by quickly retrieving similar users or items based on advanced indexing techniques. We'll leverage collaborative filtering with a MovieLens dataset, identifying similar users based on ratings represented as vectors in Qdrant, and suggesting movies they liked but we haven't seen yet. The suggested items or content should closely align with the user's interests, leading to more personalized and relevant recommendations.
|
||||
In this tutorial, you will build a mechanism that recommends movies based on defined preferences. Vector databases like Qdrant are good for storing high-dimensional data, such as user and item embeddings. They can enable personalized recommendations by quickly retrieving similar entries based on advanced indexing techniques. In this specific case, we will use [sparse vectors](/articles/sparse-vectors/) to create an efficient and accurate recommendation system.
|
||||
|
||||
Collaborative filtering works on the principle that users with similar tastes will enjoy similar movies. To implement this, we'll represent each user's ratings as vectors in a high-dimensional space using Qdrant. By indexing these vectors, we can find users with similar tastes to ours and recommend movies they liked but we haven't seen yet.
|
||||
**Privacy and Sovereignty:** Since preference data is proprietary, it should be stored in a secure and controlled environment. Our vector database can easily be hosted on [OVHcloud](https://ovhcloud.com/), our trusted [Qdrant Hybrid Cloud](/documentation/hybrid-cloud/) partner. This means that Qdrant can be run from your OVHcloud region, but the database itself can still be managed from within Qdrant Cloud's interface. Both products have been tested for compatibility and scalability, and we recommend their [managed Kubernetes](https://www.ovhcloud.com/en/public-cloud/kubernetes/) service.
|
||||
|
||||
> To see the entire output, use our [notebook with complete instructions](https://github.com/infoslack/qdrant-example/blob/main/HC-demo/HC-OVH.ipynb).
|
||||
|
||||
## Components
|
||||
|
||||
- **Dataset:** [Red Hat Interactive Learning Portal](https://developers.redhat.com/learn)
|
||||
- **Vector DB:** [Qdrant Hybrid Cloud](https://qdrant.tech) running on OpenShift.
|
||||
- **Web Host:** [OVHcloud](https://haystack.deepset.ai/)
|
||||
- **Dataset:** The [MovieLens dataset](https://grouplens.org/datasets/movielens/) contains a list of movies and ratings given by users.
|
||||
- **Cloud:** [OVHcloud](https://ovhcloud.com/), with managed Kubernetes.
|
||||
- **Vector DB:** [Qdrant Hybrid Cloud](https://qdrant.tech) running on [OVHcloud](https://ovhcloud.com/).
|
||||
|
||||
**Methodology:** We're adopting a collaborative filtering approach to construct a recommendation system from the dataset provided. Collaborative filtering works on the premise that if two users share similar tastes, they're likely to enjoy similar movies. Leveraging this concept, we'll identify users whose ratings align closely with ours, and explore the movies they liked but we haven't seen yet. To do this, we'll represent each user's ratings as a vector in a high-dimensional, sparse space. Using Qdrant, we'll index these vectors and search for users whose ratings vectors closely match ours. Ultimately, we will see which movies were enjoyed by users similar to us.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
First, download and unzip the MovieLens dataset into a local directory.
|
||||
Download and unzip the MovieLens dataset:
|
||||
|
||||
```bash
|
||||
```shell
|
||||
mkdir -p data
|
||||
wget https://files.grouplens.org/datasets/movielens/ml-1m.zip
|
||||
unzip ml-1m.zip -d data
|
||||
```
|
||||
|
||||
The necessary Python libraries are installed using `pip`, including `pandas` for data manipulation, `qdrant-client` for interfacing with Qdrant, and `python-dotenv` for managing environment variables.
|
||||
The necessary * libraries are installed using `pip`, including `pandas` for data manipulation, `qdrant-client` for interfacing with Qdrant, and `*-dotenv` for managing environment variables.
|
||||
|
||||
```python
|
||||
!pip install -U \
|
||||
pandas \
|
||||
qdrant-client \
|
||||
python-dotenv
|
||||
*-dotenv
|
||||
```
|
||||
|
||||
The `.env` file is used to store sensitive information like the Qdrant host URL and API key securely.
|
||||
|
||||
```bash
|
||||
```shell
|
||||
QDRANT_HOST
|
||||
QDRANT_API_KEY
|
||||
```
|
||||
Load all environment variables into the setup.
|
||||
Load all environment variables into the setup:
|
||||
|
||||
```python
|
||||
import os
|
||||
@@ -55,57 +59,48 @@ load_dotenv('./.env')
|
||||
|
||||
## Implementation
|
||||
|
||||
Load the user, movie, and rating data from the MovieLens dataset into pandas DataFrames to facilitate data manipulation and analysis.
|
||||
Load the data from the MovieLens dataset into pandas DataFrames to facilitate data manipulation and analysis.
|
||||
|
||||
```python
|
||||
from qdrant_client import QdrantClient, models
|
||||
import pandas as pd
|
||||
```
|
||||
|
||||
Load user data:
|
||||
```python
|
||||
# load users
|
||||
users = pd.read_csv('data/ml-1m/users.dat', sep='::', names=['user_id', 'gender', 'age', 'occupation', 'zip'], engine='python')
|
||||
users = pd.read_csv('data/ml-1m/users.dat', sep='::', names=['user_id', 'gender', 'age', 'occupation', 'zip'], engine='*')
|
||||
users.head()
|
||||
```
|
||||
|
||||
Add movies:
|
||||
```python
|
||||
# load movies
|
||||
movies = pd.read_csv('data/ml-1m/movies.dat', sep='::', names=['movie_id', 'title', 'genres'], engine='python', encoding='latin-1')
|
||||
movies = pd.read_csv('data/ml-1m/movies.dat', sep='::', names=['movie_id', 'title', 'genres'], engine='*', encoding='latin-1')
|
||||
movies.head()
|
||||
```
|
||||
|
||||
Finally, add the ratings:
|
||||
```python
|
||||
#load ratings
|
||||
ratings = pd.read_csv( 'data/ml-1m/ratings.dat', sep='::', names=['user_id', 'movie_id', 'rating', 'timestamp'], engine='python')
|
||||
ratings = pd.read_csv( 'data/ml-1m/ratings.dat', sep='::', names=['user_id', 'movie_id', 'rating', 'timestamp'], engine='*')
|
||||
ratings.head()
|
||||
```
|
||||
|
||||
**Normalize ratings**
|
||||
### Normalize the ratings
|
||||
|
||||
Sparse vectors can use advantage of negative values, so we can normalize ratings to have a mean of 0 and a standard deviation of 1
|
||||
This normalization ensures that ratings are consistent and centered around zero, enabling accurate similarity calculations.
|
||||
In this scenario we can take into account movies that we don't like.
|
||||
Sparse vectors can use advantage of negative values, so we can normalize ratings to have a mean of 0 and a standard deviation of 1. This normalization ensures that ratings are consistent and centered around zero, enabling accurate similarity calculations. In this scenario we can take into account movies that we don't like.
|
||||
|
||||
```python
|
||||
ratings.rating = (ratings.rating - ratings.rating.mean()) / ratings.rating.std()
|
||||
```
|
||||
To get the results:
|
||||
|
||||
```python
|
||||
ratings.head()
|
||||
```
|
||||
|
||||
## Preparing the data and creating a collection
|
||||
### Data preparation
|
||||
|
||||
Transform user ratings into sparse vectors, where each vector represents ratings for different movies. This step prepares the data for indexing in Qdrant.
|
||||
Now you will transform user ratings into sparse vectors, where each vector represents ratings for different movies. This step prepares the data for indexing in Qdrant.
|
||||
|
||||
First, create a collection with configured sparse vectors
|
||||
- Sparse vectors don't require to specify dimension, because it's extracted from the data automatically
|
||||
|
||||
> An explanation of using hybrid cloud with OVH can be inserted here!
|
||||
First, create a collection with configured sparse vectors. For sparse vectors, you don't need to specify the dimension, because it's extracted from the data automatically.
|
||||
|
||||
```python
|
||||
# Convert ratings to sparse vectors
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
user_sparse_vectors = defaultdict(lambda: {"values": [], "indices": []})
|
||||
@@ -114,6 +109,8 @@ for row in ratings.itertuples():
|
||||
user_sparse_vectors[row.user_id]["values"].append(row.rating)
|
||||
user_sparse_vectors[row.user_id]["indices"].append(row.movie_id)
|
||||
```
|
||||
Connect to Qdrant and create a collection called **movielens**:
|
||||
|
||||
```python
|
||||
client = QdrantClient(
|
||||
url = os.getenv("QDRANT_HOST"),
|
||||
@@ -129,7 +126,7 @@ client.create_collection(
|
||||
)
|
||||
```
|
||||
|
||||
Upload user ratings to the "movielens" collection in Qdrant as sparse vectors, along with user metadata. This step populates the database with the necessary data for recommendation generation.
|
||||
Upload user ratings to the **movielens** collection in Qdrant as sparse vectors, along with user metadata. This step populates the database with the necessary data for recommendation generation.
|
||||
|
||||
```python
|
||||
def data_generator():
|
||||
@@ -148,7 +145,7 @@ client.upload_points(
|
||||
)
|
||||
```
|
||||
|
||||
## Running the Recommendation System
|
||||
## Recommendations
|
||||
|
||||
Personal movie ratings are specified, where positive ratings indicate likes and negative ratings indicate dislikes. These ratings serve as the basis for finding similar users with comparable tastes.
|
||||
|
||||
@@ -159,9 +156,10 @@ Let's try to recommend something for ourselves:
|
||||
1 = Like
|
||||
-1 = dislike
|
||||
|
||||
Search with movies[movies.title.str.contains("Matrix", case=False)]
|
||||
|
||||
```python
|
||||
# Search with movies[movies.title.str.contains("Matrix", case=False)].
|
||||
|
||||
my_ratings = {
|
||||
2571: 1, # Matrix
|
||||
329: 1, # Star Trek
|
||||
@@ -231,7 +229,7 @@ for movie_id, score in top_movies[:5]:
|
||||
|
||||
## Result
|
||||
|
||||
```bash
|
||||
```shell
|
||||
Star Wars: Episode V - The Empire Strikes Back (1980) 20.02387858
|
||||
Star Wars: Episode VI - Return of the Jedi (1983) 16.443184379999998
|
||||
Princess Bride, The (1987) 15.840068229999996
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 223 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 85 KiB |
Reference in New Issue
Block a user