Using Vector Stores
Vector Stores enable you to search for knowledge in files uploaded to DeepFellow. Search results consist of file chunks semantically similar to the query. Such search is a fundamental step in RAG systems (retrieval-augmented generation) that enable LLMs to ground their answers in knowledge from your uploaded files.
During DeepFellow Server Installation you have to configure the necessary components of working with a vector store system:
- vector database provider - i.e. provider's specific vector database engine implementation (Qdrant or Milvus),
- embedding model - model for converting text into vectors.
Goal
This tutorial shows how to create a vector store, upload a text file to it, and how to match your query with the relevant file content. It will demonstrate using two examples that DeepFellow's semantic search mechanism can differentiate between two files depending on the asked question.
Create a Vector Store
Let's create a sample vector store.
To create a new vector make a POST /v1/vector_stores request:
curl -X 'POST' \
"https://deepfellow-server-host/v1/vector_stores" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"chunking_strategy": {
"type": "auto",
"static": {
"chunk_overlap_tokens": 100,
"max_chunk_size_tokens": 200
}
},
"name": "my_vector_store"
}'Response:
{
"project_id": "68da445c5186deb8bca2bde9",
"object": "vector_store",
"name": "my_vector_store",
"status": "completed",
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"expires_after": null,
"metadata": null,
"chunking_strategy": {
"type": "auto",
"static": {
"max_chunk_size_tokens": 200,
"chunk_overlap_tokens": 100
}
},
"bm25": false,
"id": "68ee6e626fef807dd40b2f80",
"last_active_at": 1760449091,
"created_at": 1760449091,
"expires_at": 4914049091,
"bytes": 0
}The id field is the important bit of information used to identify concrete vector store in the next steps:
It's possible to add files to the vector store at creation time. To do so, you need to specify file_ids: string[].
"id": "68ee6e626fef807dd40b2f80"During creation, each vector store is associated with the embedding model currently configured in the running DeepFellow Server upon its startup. So when you put your server down and change embedding model in config, all the vector stores created using previous embedding models become inactive until you change your settings back.
To give the vector store a BM25 index for hybrid search with BM25, set the optional bm25 field in the request body:
true: The vector store gets a BM25 index.false: The vector store gets no BM25 index.nullor omitted: TheDF_VECTOR_DATABASE__BM25setting decides. This is the default.
The bm25 field of the response shows the setting of the vector store. The setting is fixed at creation. A vector store with BM25 has a different schema, so BM25 won't turn on for an existing vector store. bm25 is independent of sparse embeddings, so a vector store can use both.
With Qdrant, a BM25 vector store requires Qdrant 1.19.2 or later. On an older Qdrant, a request that creates a BM25 vector store returns 400 Bad Request with a message that names the required version. Milvus needs no upgrade.
Upload Files
To upload a file use POST /v1/files endpoint. DeepFellow saves uploaded files to the path set by the DF_FILESTORAGE_TARGET_PATH environment variable (defaults to storage/).
Access rights
You can upload a file to a file storage using POST /v1/files endpoint. It doesn't automatically add this file to a vector store.
To add a previously uploaded file to a vector store, use the following endpoint:
POST /v1/vector_stores/{vector_store_id}/files
Let's assume you have two files containing summary description for two companies.
- secureo.txt
# Secureo Solutions
Secureo Solutions has established itself as a leading cybersecurity firm
specializing in enterprise-level threat detection and response systems. Founded
in 2018 by former government security analysts, the company offers a
comprehensive suite of services including penetration testing, security audits,
and 24/7 threat monitoring through their proprietary AI-powered platform,
ShieldWatch.- edulee.md
# Edulee Learning Platform
Edulee is an innovative online learning platform launched in 2019 that serves
over 2 million users worldwide with more than 15,000 courses in technology,
business, creative arts, and personal development. The platform partners with leading
companies like SoftABC, Searches, and ProDocs to ensure current content, while
offering flexible pricing tiers including a free option to make quality
education accessible to all.Let's upload these files. For the first one:
curl -X 'POST' \
"https://deepfellow-server-host/v1/files" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: multipart/form-data' \
-F 'file=@secureo.txt;type=text/plain' \
-F 'purpose=assistants'Response:
{
"id": "68ee6e636fef807dd40b2f81",
"project_id": "68da445c5186deb8bca2bde9",
"object": "file",
"bytes": 411,
"filename": "secureo.txt",
"purpose": "assistants",
"created_at": 1760449091,
"expires_at": 33296452691
}The id field will be used for further requests.
Uploading the second file:
curl -X 'POST' \
"https://deepfellow-server-host/v1/files" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: multipart/form-data' \
-F 'file=@edulee.md;type=text/plain' \
-F 'purpose=assistants'Response:
{
"id": "68ee6e636fef807dd40b2f82",
"project_id": "68da445c5186deb8bca2bde9",
"object": "file",
"bytes": 449,
"filename": "edulee.md",
"purpose": "assistants",
"created_at": 1760449091,
"expires_at": 33296452691
}The id field will be used for further requests.
You cannot access files from the project you don't have access rights to. Each file can be only accessed within the project whose project API Key was used in the 'Authorization' header.
Add Uploaded File to Vector Store
Now add the uploaded files to the vector store in order to be able to search in them. Note that you don't need to add all the files you've uploaded – you have full control over which files are added to vector store.
For this task use POST /v1/vector_stores/{vector_store_id}/files endpoint. Doc Chunker converts the file, and DeepFellow saves the converted document, chunks, and extracted images to the path set by the DF_FILESTORAGE_META_PATH environment variable (defaults to storage/).
Add the first file:
curl -X 'POST' \
"https://deepfellow-server-host/v1/vector_stores/68ee6e626fef807dd40b2f80/files" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "file_id": "68ee6e636fef807dd40b2f81" }'Response:
{
"project_id": "68da445c5186deb8bca2bde9",
"vector_store_id": "68ee6e626fef807dd40b2f80",
"object": "vector_store.file",
"last_error": null,
"status": "in_progress",
"usage_bytes": 411,
"chunking_strategy": {
"type": "auto",
"static": {
"max_chunk_size_tokens": 200,
"chunk_overlap_tokens": 100
}
},
"attributes": {},
"id": "68ee6e636fef807dd40b2f81",
"created_at": 1760449091
}Add the second file:
curl -X 'POST' \
"https://deepfellow-server-host/v1/vector_stores/68ee6e626fef807dd40b2f80/files" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "file_id": "68ee6e636fef807dd40b2f82" }'Response:
{
"project_id": "68da445c5186deb8bca2bde9",
"vector_store_id": "68ee6e626fef807dd40b2f80",
"object": "vector_store.file",
"last_error": null,
"status": "in_progress",
"usage_bytes": 449,
"chunking_strategy": {
"type": "auto",
"static": {
"max_chunk_size_tokens": 200,
"chunk_overlap_tokens": 100
}
},
"attributes": {},
"id": "68ee6e636fef807dd40b2f82",
"created_at": 1760449091
}In the background, each of these files will be chunked into pieces. Then for each piece a vector will be generated to be semantically associated with the given chunk.
Add Multiple Files at Once with File Batches
Adding files one at a time works well for a handful of files, but it means one request per file. To attach many already-uploaded files to a vector store in a single trackable job, use POST /v1/vector_stores/{vector_store_id}/file_batches instead. A file batch reuses the same ingestion pipeline as POST /v1/vector_stores/{vector_store_id}/files, so each member file goes through the same chunking and embedding steps.
curl -X 'POST' \
"https://deepfellow-server-host/v1/vector_stores/68ee6e626fef807dd40b2f80/file_batches" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"file_ids": ["68ee6e636fef807dd40b2f81", "68ee6e636fef807dd40b2f82"]
}'Response:
{
"project_id": "68da445c5186deb8bca2bde9",
"vector_store_id": "68ee6e626fef807dd40b2f80",
"object": "vector_store.file_batch",
"id": "68ee6e646fef807dd40b2f83",
"created_at": 1760449092,
"status": "in_progress",
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 2,
"total": 2
}
}The id field identifies the batch for the endpoints below. status reflects the batch as a whole: it stays in_progress while at least one member file is still being processed, and moves to completed, cancelled, or failed once every member file reaches a terminal status, whichever fits.
To set per-file attributes or a chunking_strategy instead of applying the same values to every file, pass a files array of { file_id, attributes, chunking_strategy } objects in place of file_ids. file_ids and files are mutually exclusive, and a single batch holds at most 2,000 files.
Adding a file that's already a member of the vector store doesn't fail the batch. If the existing membership isn't failed or cancelled, the batch keeps it as-is instead of re-scheduling ingestion.
To check on a batch later, use GET /v1/vector_stores/{vector_store_id}/file_batches/{batch_id}. It returns the same shape as the creation response, with status and file_counts reflecting the current state.
To list the files that belong to a batch, use GET /v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files. It supports the same pagination and status filtering as listing a vector store's files, and returns entries in the same shape.
To stop a batch that's still processing, use POST /v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel. Member files still in_progress become cancelled; files that already finished keep their outcome. Calling cancel on a batch with no in_progress files has no effect.
Instead of polling GET /v1/vector_stores/{vector_store_id}/file_batches/{batch_id} for a batch to finish, configure a webhook to be notified as soon as it reaches a terminal status. See Webhooks.
Chunk Size
DeepFellow splits each file into chunks that fit the vector store's embedding model. Doc Chunker measures the chunks with the tokenizer of that model, so a chunk never holds more tokens than the model embeds at once.
The chunk size depends on chunking_strategy.type:
auto: 512 tokensstatic: the value ofmax_chunk_size_tokens
If the embedding model accepts fewer tokens than this size, the model's limit applies instead. Doc Chunker sets the overlap between chunks itself, so DeepFellow ignores chunk_overlap_tokens when chunking. The field is still validated: it must be less than max_chunk_size_tokens and defaults to 400, so set it explicitly when max_chunk_size_tokens is 400 or less.
DeepFellow fetches the model's tokenizer from DeepFellow Infra the first time it chunks a file for that model. If DeepFellow Infra has no tokenizer for the model, for example for a remote provider's model, Doc Chunker measures the chunks with its default tokenizer. If DeepFellow Infra is temporarily unavailable, DeepFellow processes the file again later.
Files added to a vector store before DeepFellow chunked with the model's tokenizer keep their chunks. A vector store migration chunks them again for the target model.
Skip Chunking
Set chunking_strategy.type to skip to skip chunking entirely: each file becomes exactly one chunk containing its whole content, unchanged. Use this for files you already split into right-sized pieces and want the vector store to index as-is.
{
"chunking_strategy": {
"type": "skip"
}
}skip overrides the vector store's server-side chunking configuration for that request. The resulting file's chunking_mode is reported as skip in the response.
Describe Images before Chunking
Set image_processing_mode to description when you add a file to a vector store to have a vision model describe each image in the file before chunking. The description becomes part of the file's text, so image content becomes searchable together with the rest of the file. The default value, ignore, skips image descriptions and keeps the file's original text only.
POST /v1/vector_stores/{vector_store_id}/files and POST /v1/vector_stores's image_processing_mode accepts the same values when you add files through file_ids at creation time.
{
"file_id": "68ee6e636fef807dd40b2f81",
"image_processing_mode": "description"
}DeepFellow Server describes the images itself and keeps the descriptions next to the file's converted document, so later requests reuse them. If a file was already converted without image descriptions, for example through an earlier upload, a later request with image_processing_mode set to description adds the descriptions without converting the file again. GET /v1/files/{file_id}/text with image_mode set to descriptions does the same. See Image Descriptions in DeepFellow Server.
Search
You cannot search in files from the project you don't have access rights to. Each file can be only accessed within the project whose project API Key was used in the 'Authorization' header.
Invent a query that can be related to the Edulee file and not to the Secureo. Then ask vector database using this query to show that chunks are matched only with the relevant file.
"query": "I want to learn about computers"Vector search uses vector similarity measure (like a cosine similarity) to match a query with a relevant text from a vector store.
For this task use POST /v1/vector_stores/{vector_store_id}/search endpoint.
To search vector store for three best results type:
curl -X 'POST' \
"https://deepfellow-server-host/v1/vector_stores/68ee6e626fef807dd40b2f80/search" \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"query": "I want to learn about computers",
"rewrite_query": true,
"max_num_results": 3
}'Response:
{
"object": "vector_store.search_results.page",
"search_query": "I want to learn about computers",
"data": [
{
"file_id": "68ee6e636fef807dd40b2f82",
"filename": "edulee.md",
"score": 0.5061247944831848,
"attributes": {},
"content": [
{
"text": ", and ProDocs to ensure current content, while\noffering flexible pricing tiers including a free option to make quality\neducation accessible to all. \n",
"type": "text",
"offset": 0,
"metadata": {}
}
]
},
{
"file_id": "68ee6e636fef807dd40b2f82",
"filename": "edulee.md",
"score": 0.49376875162124634,
"attributes": {},
"content": [
{
"text": "erves\nover 2 million users worldwide with more than 15,000 courses in technology,\nbusiness, creative arts, and personal development. The platform partners with leading\ncompanies like SoftABC, Searches",
"type": "text",
"offset": 0,
"metadata": {}
}
]
},
{
"file_id": "68ee6e636fef807dd40b2f82",
"filename": "edulee.md",
"score": 0.48902779817581177,
"attributes": {},
"content": [
{
"text": " arts, and personal development. The platform partners with leading\ncompanies like SoftABC, Searches, and ProDocs to ensure current content, while\noffering flexible pricing tiers including a free opti",
"type": "text",
"offset": 0,
"metadata": {}
}
]
}
],
"has_more": false,
"next_page": null
}Vector store returned chunks from the file containing info about education platform. It's expected as your query was related to learning.
DeepFellow Server sorts results by score, highest first. What score measures depends on the reranker setting (DF_VECTOR_DATABASE__RERANKER__ACTIVE):
- Without the reranker,
scoreis the cosine similarity between the query and the chunk. A hybrid search, on a store with BM25 or sparse vectors, returns the RRF score that combines its lists instead. - With the reranker active,
scoreis the reranker's relevance score for the chunk. DeepFellow Server doesn't normalize it, so its scale depends on the reranker model.
Hybrid Search with BM25
Dense vectors match the meaning of a query, but they often miss exact strings such as postal codes, product codes, and abbreviations. BM25 matches these strings. If you create a vector store with bm25 set to true, its collection also stores a BM25 index of the chunk text. Milvus and Qdrant compute the index themselves, without an extra model.
The BM25 index lowercases the text and splits it into words. It doesn't stem words or remove stopwords. Polish characters work, and a hyphen splits a word in two, so AB-123 becomes ab and 123.
A search in a BM25 vector store runs one query for each list the vector store has:
- Dense
- Sparse, if the vector store uses sparse embeddings
- BM25
The server fuses the lists with Reciprocal Rank Fusion (RRF) with k=60. For each list a result appears in, RRF adds 1/(60 + rank) to its score, where the top result has rank 1. Without a reranker, the result score is this raw RRF score, about 0.016 to 0.05 for the top results. filters apply to every list. DF_VECTOR_DATABASE__VECTOR_THRESHOLD applies to the dense list only.
Without a reranker, the server returns the first max_num_results results in RRF order. With a reranker active, each list returns up to the candidate pool set by DF_VECTOR_DATABASE__RERANKER__OVERSAMPLING and DF_VECTOR_DATABASE__RERANKER__MIN_FETCH_K, and the reranker receives every fused candidate, up to the pool times the number of lists. It picks the top max_num_results results by how well they match the query and returns its relevance score as score, in place of the RRF score.
The same applies to a vector store with sparse embeddings and no BM25. With a reranker active, the reranker receives up to twice the candidate pool, the dense and the sparse candidates, not only the first candidates after fusion.
In a vector store with BM25 and no reranker, the score comes only from the position of the result on the dense and BM25 lists, not from how well the result matches the query. The score orders results within one query, not across queries. To judge relevance, turn on the reranker.
Refine Search
Sometimes results are not satisfactory and the query needs refinement. You can adjust your search results using the following request body parameters:
{
"filters": {
"key": "string",
"type": "eq", // different filter types are available [q, ne, gt, gte, lt, lte, in, nin]
"value": "string"
},
"max_num_results": 10,
"ranking_options": {
"ranker": "auto",
"score_threshold": 0.4
}
}filters can narrow down the scope of vectors to search.
max_num_results limits the number of vectors returned.
To return only results with score above a threshold, set score_threshold in ranking_options. DeepFellow Server applies score_threshold only with the reranker active, and compares it with the reranker's relevance score, also in a vector store with BM25. Choose the threshold for the scale of your reranker model. Without the reranker, DeepFellow Server ignores score_threshold and filters results by DF_VECTOR_DATABASE__VECTOR_THRESHOLD only.
If a request has no score_threshold, DeepFellow Server uses the default from DF_VECTOR_DATABASE__RERANKER__SCORE_THRESHOLD, when your administrator sets it. A score_threshold in the request takes precedence. To skip the default for one request, send a score_threshold below the lowest score your reranker returns, for example a negative value: null in a request means no value, so the default still applies. A file_search Tool created in the Web UI sets no threshold, so the default applies to it and drops chunks that don't answer the question in chat. A Tool defined through the API can set its own ranking_options.score_threshold, which takes precedence over the default. When no threshold applies, a search returns its full top results, even when no document answers the query.
filters matches file attributes: the key-value pairs you set when you add a file to the vector store or update its attributes. After an attribute update, search matches the new values.
The reserved keys df_kind, df_summary_index, and df_summary_run_id match the metadata the server sets on every vector. For example, {"key": "df_kind", "type": "eq", "value": "doc_summary"} returns document summaries only. The server rejects attributes with these keys.
filters doesn't match the metadata Doc Chunker attaches to chunks, such as headings, labels, or self_refs. An attribute with the same name as one of these keys matches the attribute's own value. Right after an update, such a filter can still match the chunks of files added on an earlier version until the server finishes updating file attributes in the background.
The Doc Chunker metadata stays available. To read it for a search result, take the result's file_id and the chunk's offset, and find the chunk with the same offset in GET /v1/vector_stores/{vector_store_id}/files/{file_id}/content. The chunk's metadata holds the Doc Chunker keys and its chunk_index, which GET /v1/vector_stores/{vector_store_id}/files/{file_id}/chunks/{chunk_index}/fragment accepts.
Details on these parameters can be found in OpenAI API documentation.
How to Use Search Results
Search results can be used by LLMs to provide additional context in prompt to improve their answer in comparison to answering without context.
Prompt without context:
- Prompt: "What is Edulee?"
- LLM answer: "I don't have any specific information about Edulee."Prompt with extra context:
- Prompt:"""
<!-- This part is added programmatically in your app -->
Provided information in the context below, please answer the user prompt.
<context>
<entry>
File: edulee.md
[...] erves\nover 2 million users worldwide with more than 15,000 courses
in technology,\nbusiness, creative arts, and personal development.
The platform partners with leading\ncompanies like SoftABC, Searches [...]
</entry>
<entry>
File: edulee.md
[...] arts, and personal development. The platform partners with leading\ncompanies
like SoftABC, Searches, and ProDocs to ensure current content,
while\noffering flexible pricing tiers including a free opti [...]
</entry>
</context>
<!-- End of added context -->
What is Edulee?
"""
- LLM answer: "Edulee is a learning platform that offers 15,000 courses on various topics."Final Notes
Vector stores open doors to building knowledge bases in your application. This is a major topic, programmatically based on RAG. Implementing knowledge bases securely is challenging but DeepFellow takes care of security and data safety for you.
For the model to retrieve from a vector store on its own, without you copying search results into the prompt yourself, see How to Create Your RAG.
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.