Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
61 posts found
Agentic RAG and GraphRAG: When Classic RAG Is Not Enough
Artificial Intelligence PART 13

Agentic RAG and GraphRAG: When Classic RAG Is Not Enough

Classic RAG handles most questions whose answer sits in one place; on multi-hop questions an agent that uses retrieval as a tool found the right source but spent 3 calls, 11 times the tokens and 30 times the time. GraphRAG's first step produced fragmented entities with a small model, and long context with the whole corpus in the prompt tied classic RAG at 7/10.

8 Nov 2026 14 min 8
Measuring RAG: Recall@k, MRR, nDCG, Faithfulness and Groundedness
Artificial Intelligence PART 12

Measuring RAG: Recall@k, MRR, nDCG, Faithfulness and Groundedness

Measuring RAG means measuring retrieval against labelled sources (recall@k, MRR, nDCG) and generation with an LLM judge (groundedness, relevance) separately. We compare four retrieval methods on 30 questions in C#, show Microsoft.Extensions.AI.Evaluation giving 5 to an answer that misses the question, and cut a 1 min 42 s test to 1.1 s with response caching.

8 Nov 2026 12 min 8
Authorization and Security in RAG: Document-Level Permissions, Multi-Tenant Filters and Indirect Prompt Injection
Artificial Intelligence PART 11

Authorization and Security in RAG: Document-Level Permissions, Multi-Tenant Filters and Indirect Prompt Injection

In RAG, authorization isn't a request in the prompt but the WHERE clause of the retrieval query: told "don't reveal this", gemma3:4b told a customer the staff discount. We take tenant and ACL from the token into the query with EF Core 10 named query filters, and measure an HNSW filter returning 1 result instead of 10 and a poisoned reader review asking for card numbers.

8 Nov 2026 11 min 6
Putting Context into the Prompt: Citations, Context Budget and "I Don't Know" on Low Scores
Artificial Intelligence PART 10

Putting Context into the Prompt: Citations, Context Budget and "I Don't Know" on Low Scores

Packing chunks as short id-tagged blocks within a token budget, getting the answer and source ids via structured output and validating the ids in code makes citations trustworthy; but a valid citation is not a correct answer. Because Turkish similarity scores overlap, a pre-model "I don't know" threshold only catches the obvious cases.

8 Nov 2026 12 min 7
Reranking and Query Transformation: Cross-Encoders, Query Rewriting and HyDE
Artificial Intelligence PART 09

Reranking and Query Transformation: Cross-Encoders, Query Rewriting and HyDE

Retrieve wide, return narrow: passing hybrid search's 10 candidates through a reranker that reads question and chunk together raised the right chunk in first place from 15 to 23 of 30 questions, at 3.2 seconds per question. We measure conversational query rewriting, multi-query, HyDE and self-query on the same set and show when they hurt.

8 Nov 2026 14 min 8
Hybrid Search and Reciprocal Rank Fusion: Combining Keyword and Vector Search
Artificial Intelligence PART 08

Hybrid Search and Reciprocal Rank Fusion: Combining Keyword and Vector Search

Vector search misses SKUs, ISBNs and rare terms; adding keyword search with PostgreSQL tsvector (turkish) and merging the two lists by rank rather than score, with Reciprocal Rank Fusion, closes that gap. We build it with EF Core, a single SQL query and VectorData HybridSearchAsync, and measure vector, keyword and hybrid recall on 30 questions.

8 Nov 2026 14 min 15
Vector Search with EF Core (2): PostgreSQL pgvector, HNSW Index and Dapper
Artificial Intelligence PART 07

Vector Search with EF Core (2): PostgreSQL pgvector, HNSW Index and Dapper

With Pgvector.EntityFrameworkCore a Vector property, an HNSW index and CosineDistance ordering take a few lines; the real risk is silent failures: an index built with vector_l2_ops was never used by a cosine query, and without ReloadTypes Npgsql could not write the vector. Search with a permission filter, EXPLAIN checks, halving storage with halfvec (identical top-5 for 30 of 30 questions) and the same query with Dapper.

8 Nov 2026 12 min 7
Vector Search with EF Core (1): SQL Server 2025 vector Type, VectorDistance and EF Core 11 VectorSearch
Artificial Intelligence PART 06

Vector Search with EF Core (1): SQL Server 2025 vector Type, VectorDistance and EF Core 11 VectorSearch

In EF Core 10 a SQL Server 2025 vector column is mapped with a SqlVector<float> property and HasColumnType("vector(768)"), and search is done exactly with EF.Functions.VectorDistance. We build the code and inspect the real SQL EF Core generates: queries without a projection fetch the vector too, the preview vector index and VECTOR_SEARCH, and what EF Core 11 brings. SQL Server 2025 was not run for this post.

8 Nov 2026 10 min 7
Choosing a Vector Database: pgvector, SQL Server 2025, Qdrant, Azure AI Search and Elasticsearch
Artificial Intelligence PART 05

Choosing a Vector Database: pgvector, SQL Server 2025, Qdrant, Azure AI Search and Elasticsearch

Try your existing database's vector support first, and tune the ANN index by measuring recall on your own data. On a 100,000-vector pgvector table exact search took 237 ms and HNSW 1 ms, but recall stayed at 0.83 with the default ef_search; with a filter, HNSW forced onto the index returned zero rows while an iterative scan found 10. HNSW, IVFFlat, DiskANN, choosing a metric, and five options compared.

8 Nov 2026 12 min 7
Chunking Strategies: Token-Based, Header-Based, Semantic, Overlap and Contextual Retrieval
Artificial Intelligence PART 04

Chunking Strategies: Token-Based, Header-Based, Semantic, Overlap and Contextual Retrieval

There is no single best chunk size; choose a strategy by measuring recall and the context budget together. On the same 30 Turkish questions, 64-token windows ranked the right section first 19 times and header-based chunks 16 times; 256 tokens raised recall@5 to 28 but grew the prompt to 1,122 tokens. We compare fixed size, overlap, semantic, parent-child and Contextual Retrieval with gemma3:4b using real measurements.

8 Nov 2026 10 min 8
Document Ingestion: Clean Text, Metadata and Incremental Updates from PDF, HTML and Markdown
Artificial Intelligence PART 03

Document Ingestion: Clean Text, Metadata and Incremental Updates from PDF, HTML and Markdown

RAG quality starts at ingestion: a "fi" ligature from a PDF made Contains("fiyat") return false, a page number landed in the middle of a section, and an HTML menu leaked into a chunk. Clean text, metadata on every chunk, a pipeline with partial success using Microsoft.Extensions.DataIngestion (preview), incremental updates with content hashes, and removing deleted documents from the index.

8 Nov 2026 14 min 9
Choosing an Embedding Model: Dimensions, Multilinguality, Turkish and Cost
Artificial Intelligence PART 02

Choosing an Embedding Model: Dimensions, Multilinguality, Turkish and Cost

Choose an embedding model by measuring it in your own language on your own question set, not by the leaderboard average: on the same content nomic-embed-text ranked the right section first for 26 of 30 questions in English but only 16 in Turkish. We measure with recall@k and MRR and look at prefixes, Matryoshka dimensions, storage, silent truncation and the risk of old vectors after a model switch, with real output.

8 Nov 2026 13 min 11
Blog Map