librain stats
- okunan makale
- 67
- Qdrant’taki parça
- 2.470
- uydurma atıf
65–67, şimdi 0
gh repo view librain
- COMMIT
- 166
- yıldız
- ★ 1
- dosya
- 665
- lisans
- MIT
- İLK COMMIT
- 1 Mayıs 2026
- SON COMMIT
- 18 Kasım 2026
- C# %97,9
- Shell %1,6
- TeX %0,5
01LIBRAIN
Bilimsel makaleleri okuyup atıflara dayanan hipotezler öneren, .NET 10 ile yazılmış açık kaynaklı, çok ajanlı bir RAG sistemi.
README orijinal haliyle (İngilizce)
A multi-agent RAG system that reads scientific papers and proposes new hypotheses, built in .NET 10.- Reader Agent: extracts text from arXiv PDFs, chunks it, embeds it and stores it in Qdrant.
- Synthesis Agent: retrieves the top chunks and asks Claude for citation-grounded hypotheses.
- Evaluator Agent: LLM-as-a-Judge with a fixed rubric (plausibility, novelty, clarity).
- Discovery Mode: the part that goes beyond the sources is flagged as novelClaim.
- Web UI (React + Vite + TypeScript): Library, Ask, Discover, Compare and History; long runs show live progress.
POST /api/discover# CASE_STUDY.md
LIBRAIN
Sorun
- RAG ve yapay zekâ ajanlarıyla ilgili eğitimlerin çoğu Python’la yazılmış. .NET kullanan ekiplerin duyduğu mesaj da hep aynı: “yapay zekâ Python ister.”
- Bir de şu var: bir LLM makaleler arasında bağ kurarken, hiç getirilmemiş kaynaklara atıf yapabiliyor.
Yaklaşım
- Baştan sona .NET 10 ile kurulmuş, eksiksiz bir çok ajanlı retrieval pipeline’ı: önce Reader, sonra Synthesis, en son Evaluator.
- Paralel çalışan Discovery Mode, yanıtın spekülatif kısmını novelClaim (yeni iddia) adlı ayrı bir alana koyuyor. ClaimValidator (Claude Haiku 4.5) da bu alandaki her cümleyi GROUNDED, EXTRAPOLATED ya da RISKY diye etiketliyor ve yanına bir halüsinasyon olasılığıyla gerekçesini yazıyor. Demoda bu etiketler Dayanaklı, Varsayımsal ve Riskli olarak görünüyor.
- Düz C# ile yazılmış, araya hiçbir modelin girmediği bir atıf sözleşmesi (DiscoveryContract.cs), getirilmemiş bir parçaya yapılan her atıfı eliyor.
- İddia kontrolleri şüphede güvenli tarafta kalıyor: validator kullanılabilir bir karar döndürmezse sonuç güvenli sayılmıyor, en yüksek riskle işaretleniyor.
- 67 makalearXiv
- Readerchunk + embed
- Qdrant2.470 parça
- SynthesisDiscovery
- EvaluatorClaimValidator
- Hipotezleratıflı
Ne yaptım
- Hiçbir ajan framework’ü kullanmadan, düz C# ile yazılmış ajanlar: Claude (yazan Sonnet 4.6, kontrol edip puanlayan Haiku 4.5), OpenAI embedding’leri (text-embedding-3-small) ve Qdrant. Her adım bir korelasyon ID’siyle loglanıyor.
- Üç sistemli karşılaştırma için baseline ajanları (naive RAG, tek bir LLM), deneyler için bir CLI, bir de modeller arası testler için OpenAI’a taşınmış bir sürüm.
- React, Vite ve TypeScript ile, İngilizce ve Türkçe bir web arayüzü: Library, Ask, Discover, Compare ve History. Uzun süren çalıştırmalar önce adım adım ilerlemeyi, sonra sonucu gönderiyor; kaydedilen her çalıştırma aynı zamanda, korelasyon ID’siyle bulunan bir denetim kaydı.
- Explore: kayıtlı her keşif 10 üzerinden bir not alıyor. Her birinin kendi sayfası var; bir de istatistikler ve validator’ın gerçek kararları üzerine kurulu bir tahmin oyunu, “Spot the risk”.
- Makaleler arXiv ID’siyle de eklenebiliyor. Tek bir docker compose komutu Qdrant’ı, API’yi ve arayüzü birlikte ayağa kaldırıyor. Herkese açık demoda API Docker ile Render’da, site GitHub Pages’te, makale kütüphanesi de Qdrant Cloud’da çalışıyor ve hepsi GitHub Actions ile yayına alınıyor. İsteğe bağlı bir API key ve istemci başına rate limit API’yi koruyor, Claude çağrıları da hata alınca jitter’lı aralıklarla yeniden deneniyor.
- 19 Kasım 2026’daki CI çalıştırmasında 851 test: backend’de 282 (xUnit), web arayüzünde 569 (Vitest). Backend testleri, makaledeki çalışmanın kayıtlı Discovery sonuçlarının hepsini (30 tane) güncel koddan yeniden geçiriyor ve her biri aynı puanları vermek zorunda.
- librain.erenmutlu.me adresinde herkese açık bir demo. Hazır modda 88 fikrin hepsi ücretsiz okunabiliyor, hesap gerekmiyor. Kendi iki konunu çalıştırmak için kendi Anthropic ve OpenAI API key’lerin gerekiyor, bir çalıştırma yaklaşık 7 sent tutuyor.
- Zenodo’da yayımladığım, projeyi anlatan bir makale. Bir de ilk 46 keşfi sade bir dille anlatan, İngilizce ve Türkçe bir kitapçık (PDF).
Sonuç
- okunan makale
- 67
- Qdrant’taki parça
- 2.470
- uydurma atıf
65–67, şimdi 0
- 41 makalelik, farklı alanlardan oluşan bir makale kütüphanesinde sözleşmesiz baseline 65–67 uydurma atıf üretti. Sözleşmeli pipeline bunların hiçbirini geçirmedi. (Sayılan atıflardan ikisi, modelin prompt’taki kaynak biçimini aynen tekrarlamasıydı; bunların çözümlenip çözümlenmediği kayda geçmemiş.)
- 18 Kasım 2026’da LIBRAIN 88 Discovery fikri kaydetti: dokuz alanda 46 çalıştırma (Deney 8), alanlar arası 24 çalıştırma, müzik, hukuk ve yaban hayatı üzerine 12 makale eklendikten sonra da 18 çalıştırma daha (67 makale, 2.470 parça). 88 fikrin API maliyeti toplam 5,88 ABD doları, tanesi yaklaşık 7 sent. Bir çalıştırma yaklaşık 20 saniye sürüyor.
- İlk 46 çalıştırmada hiç uydurma atıf çıkmadı, validator da 73 spekülatif cümleden 4’ünü riskli olarak işaretledi. Bunlardan biri PharmAgents’ın %37,94’lük başarı oranını bir “tavan” diye anıyordu ve %72 olasılıkla riskli işaretlendi. Makalede başarı oranı %15,72’den %37,94’e çıkıyor.
- 10 üzerinden notları LIBRAIN’in kendi değerlendiricisi, yani bir model veriyor. Fikirlere hiçbir insan not vermedi. En yüksek not 8.1: hayvan takibi × öğrenilmiş fizik simülatörleri (E5). 7.8’in üstünde başka fikir yok. En yüksek notları yaban hayatının korunması, programlama eğitimi, salgın tahmini ve spor analitiği alanlarındaki fikirler aldı. İki fikir aynı istekle dörder kez daha çalıştırıldı ve her tekrar daha düşük not aldı, düşüş en fazla 2’ye yakındı. Bu yüzden demoda her fikir ilk çalıştırmasıyla duruyor.
- Her biri kanıtlanmış bir keşif değil, aday bir hipotez: kanıt, hipotezin çıkış noktasını destekliyor; yeni kısmın ise hâlâ gerçek bir deneyle sınanması gerekiyor.
F4 · Yapay zekâ × futbol · aday hipotez
Kornerleri bir fizik simülasyonu gibi prova etmek
Korner vuruşunda her oyuncuyu, öğrenilmiş bir fizik simülatöründeki bir parçacık gibi ele al; böylece TacticAI benzeri bir asistan yalnızca başlangıç dizilişini değil, hareket planlarının tamamını deneyebilir.
corner kick tactic generation and player positioning × learned physics simulators with graph networks
Nasıl sınanır: simülatör gerçek kornerlerin takip verileriyle eğitilir; görmediği maçlarda tahmin ettiği koşuların gerçekte olanlarla örtüşüp örtüşmediğine bakılır.
Ne öğrendim
- Sentetik testler, gerçek dosyalarla yapılan bir smoke test’in yerini tutmuyor. Tek bir gerçek arXiv PDF’i, yeşil yanan yedi birim testin kaçırdığı bir kelime boşluğu hatasını ve bölüm tespitindeki açıkları ortaya çıkardı.
- Rate limit neyse ona uy: embedding batch’lerini hesabın gerçek tier sınırına göre ayarlamak, retry mantığı yazmaktan daha iyi sonuç verdi.
Bütün hikâye, adım adımLIBRAIN’in nasıl düşündüğünü gör Canlı demo Makale (DOI) Keşifler, sade dille (PDF, TR + EN)
LIBRAIN/Agents/ReaderAgent.csGitHub’da aç
1using System.Diagnostics;2using LIBRAIN.Embeddings;3using LIBRAIN.Reading;4using LIBRAIN.Storage;5 6namespace LIBRAIN.Agents;7 8public sealed class ReaderAgent(9 ILogger<ReaderAgent> logger,10 PdfTextExtractor extractor,11 RecursiveChunker chunker,12 IEmbeddingClient embeddings,13 IPaperStore repository)14{15 private readonly ILogger<ReaderAgent> _logger = logger;16 private readonly PdfTextExtractor _extractor = extractor;17 private readonly RecursiveChunker _chunker = chunker;18 private readonly IEmbeddingClient _embeddings = embeddings;19 private readonly IPaperStore _repository = repository;20 21 public async Task<IngestResult> IngestAsync(22 Stream pdfStream,23 string paperId,24 CancellationToken ct = default,25 PaperMetadata? metadata = null)26 {27 var correlationId = Guid.NewGuid();28 using var scope = _logger.BeginScope(new Dictionary<string, object>29 {30 ["correlationId"] = correlationId,31 ["paperId"] = paperId,32 });33 34 var sw = Stopwatch.StartNew();35 _logger.LogInformation("Ingest started for {PaperId}", paperId);36 37 var doc = _extractor.Extract(pdfStream);38 var chunks = _chunker.Chunk(doc.FullText, doc.Pages);39 if (chunks.Count == 0)40 {41 _logger.LogWarning("No chunks produced; nothing to persist");42 return new IngestResult(paperId, 0, correlationId, metadata?.Title ?? doc.Title);43 }44 45 var contents = chunks.Select(c => c.Content).ToArray();46 var vectors = await _embeddings.GenerateAsync(contents, ct);47 48 var title = !string.IsNullOrWhiteSpace(metadata?.Title) ? metadata.Title49 : string.IsNullOrWhiteSpace(doc.Title) ? paperId : doc.Title;50 var authors = metadata?.Authors is { Count: > 0 } ? metadata.Authors : doc.Authors;51 var year = metadata?.Year ?? doc.Year;52 var ingestedAt = DateTime.UtcNow;53 var records = new ChunkRecord[chunks.Count];54 for (int i = 0; i < chunks.Count; i++)55 {56 var c = chunks[i];57 records[i] = new ChunkRecord(58 PaperId: paperId,59 ChunkIndex: c.ChunkIndex,60 Content: c.Content,61 Embedding: vectors[i],62 Title: title,63 Authors: authors,64 Year: year,65 Section: c.Section,66 PageNumber: c.PageNumber,67 IngestedAt: ingestedAt);68 }69 70 await _repository.PersistAsync(records, ct);71 72 _logger.LogInformation(73 "Ingest completed: {ChunkCount} chunks in {ElapsedMs}ms",74 chunks.Count,75 sw.ElapsedMilliseconds);76 77 return new IngestResult(paperId, chunks.Count, correlationId, title);78 }79}LIBRAIN/Agents/SynthesisAgent.csGitHub’da aç
1using System.Diagnostics;2using System.Text;3using System.Text.Json.Nodes;4using LIBRAIN.Llm;5using LIBRAIN.Models;6using LIBRAIN.Storage;7using Microsoft.Extensions.Options;8 9namespace LIBRAIN.Agents;10 11public sealed class SynthesisAgent(12 ILogger<SynthesisAgent> logger,13 ILlmClient llm,14 IOptions<ModelOptions> modelOptions)15{16 private readonly ILogger<SynthesisAgent> _logger = logger;17 private readonly ILlmClient _llm = llm;18 private readonly string _synthesisModel = ModelSelection.SynthesisModel(modelOptions.Value);19 20 private const string SystemPromptText = """21 You are a research synthesis assistant for a literature-review system. You are given22 a user query and a numbered list of source excerpts retrieved from academic papers.23 24 Form a single, conservative hypothesis grounded ONLY in the provided sources. Cite by25 source number. List any claim in your hypothesis that is NOT directly supported by a26 cited source in `unsupported_claims`; if all claims are supported, return an empty array.27 28 If the sources are insufficient to form any defensible hypothesis: set `confidence`29 below 0.3, populate `unsupported_claims` with what's missing, and write a hypothesis30 stating the limitation explicitly (e.g., "The provided sources do not address X").31 32 Always call the `submit_hypothesis` tool. Do not respond in plain text.33 """;34 35 // Schema is raw JSON because Anthropic.SDK.Messaging.Property in 5.10 has no Items field;36 // it can't express array<integer> via the typed builder. Function's (string, string, JsonNode)37 // ctor accepts a parsed schema directly.38 private const string ToolSchemaJson = """39 {40 "type": "object",41 "properties": {42 "hypothesis": { "type": "string", "description": "A single conservative claim grounded only in the provided sources." },43 "citation_indices": { "type": "array", "items": { "type": "integer" }, "description": "1-based indices into the SOURCES block, ordered by relevance." },44 "confidence": { "type": "number", "description": "Self-reported 0.0-1.0; lower if sources are sparse or contradictory." },45 "unsupported_claims": { "type": "array", "items": { "type": "string" }, "description": "Substrings of the hypothesis that are NOT directly supported by the cited sources. Empty array if all claims are supported." }46 },47 "required": ["hypothesis", "citation_indices", "confidence", "unsupported_claims"]48 }49 """;50 51 private static readonly LlmTool SubmitHypothesisTool =52 LlmTool.FromJsonSchema("submit_hypothesis", "Submit a citation-grounded hypothesis.", ToolSchemaJson);53 54 public async Task<SynthesisResult> SynthesizeAsync(55 string query,56 IReadOnlyList<SearchHit> chunks,57 Guid? correlationId = null,58 CancellationToken ct = default)59 {60 var corrId = correlationId ?? Guid.NewGuid();61 using var scope = _logger.BeginScope(new Dictionary<string, object>62 {63 ["correlationId"] = corrId,64 ["chunkCount"] = chunks.Count,65 });66 67 if (chunks.Count == 0 || chunks.All(c => string.IsNullOrWhiteSpace(c.Content)))68 {69 _logger.LogWarning("Synthesis skipped: no usable source chunks");70 return new SynthesisResult(71 Hypothesis: "Insufficient sources to form a hypothesis.",72 Citations: Array.Empty<SynthesisCitation>(),73 Confidence: null,74 UnsupportedClaims: Array.Empty<string>(),75 CorrelationId: corrId);76 }77 78 var sw = Stopwatch.StartNew();79 var request = new LlmRequest(80 Model: _synthesisModel,LIBRAIN/Agents/ClaimValidatorAgent.csGitHub’da aç
1using System.Diagnostics;2using System.Text;3using System.Text.Json.Nodes;4using LIBRAIN.Llm;5using LIBRAIN.Storage;6 7namespace LIBRAIN.Agents;8 9// Stage 2 of the claim-level hallucination mitigation prototype. After10// DiscoveryAgent produces novelClaim + extrapolation_basis, this agent runs a11// secondary Haiku-backed pass that scores each sentence of novel_claim against the12// retrieved chunks and classifies it as GROUNDED, EXTRAPOLATED, or RISKY using the13// rubric's hallucination definition. The aggregate risk is C#-computed as the max14// of per-sentence probabilities to keep the score halo-resistant (mirroring the15// Phase 2 Evaluator pattern).16public sealed class ClaimValidatorAgent(17 ILogger<ClaimValidatorAgent> logger,18 ILlmClient llm)19{20 private readonly ILogger<ClaimValidatorAgent> _logger = logger;21 private readonly ILlmClient _llm = llm;22 23 private const string SystemPromptText = """24 You are a claim-level factuality validator. You are given the novel_claim25 portion of a discovery hypothesis and the retrieved source chunks that were26 available to the synthesizer. Your job is to split novel_claim into its27 constituent sentences and classify each sentence under three statuses:28 29 - GROUNDED: the sentence is directly supported by at least one retrieved30 chunk. Cite the chunk(s) in supporting_chunks as "paper_id:chunk_index".31 - EXTRAPOLATED: the sentence is speculative or hypothesis-framed. It goes32 beyond the retrieved evidence but does NOT assert a specific factual claim33 as established. Examples: "X could enable Y", "this suggests Y", "future34 work may show Y". Speculation framed as hypothesis is EXTRAPOLATED, not35 RISKY.36 - RISKY: the sentence states a SPECIFIC FACTUAL CLAIM (a mechanism, a37 quantity, a named entity, a date, an attribution, or a process detail) as38 if it were established knowledge, AND that claim is not supported by any39 retrieved chunk. The hallucination signature is confident factual framing40 without retrieval support. Examples that ARE risky:41 * "EEG biomarkers determine drug-target binding in real time" (specific42 mechanism stated as fact, no retrieval support)43 * "GraphCast achieves 98% accuracy on protein folding" (fabricated stat)44 * "PharmAgents was released by DeepMind in 2024" (wrong attribution)45 Examples that are NOT risky (these are EXTRAPOLATED):46 * "Weather forecasting algorithms could plausibly transfer to protein47 folding via shared mathematical structure"48 * "Real-time biomarker integration may eventually inform drug discovery"49 Hedging language ("could", "may", "suggests", "is hypothesized") is the50 marker that distinguishes EXTRAPOLATED from RISKY. Confident factual framing51 of an unsupported specific claim is the marker that distinguishes RISKY.52 53 For each sentence also return factual_hallucination_probability in [0, 1].54 GROUNDED ≈ 0.0, EXTRAPOLATED ≈ 0.1–0.3, RISKY ≈ 0.6–1.0. Use the full55 continuous range; do not snap to round numbers.56 57 Provide a one-sentence rationale per claim describing why you chose the58 status. Also return an aggregate_risk in [0, 1] (the application will59 recompute the canonical aggregate in code; your aggregate is a sanity60 check).61 62 Always call the `submit_claim_validation` tool. Do not respond in plain63 text.64 """;65 66 private const string ToolSchemaJson = """67 {68 "type": "object",69 "properties": {70 "claims": {71 "type": "array",72 "minItems": 1,73 "items": {74 "type": "object",75 "properties": {76 "sentence": { "type": "string", "description": "Exact sentence from novel_claim." },77 "factuality_status": { "type": "string", "enum": ["GROUNDED", "EXTRAPOLATED", "RISKY"] },78 "supporting_chunks": { "type": "array", "items": { "type": "string" }, "description": "List of 'paper_id:chunk_index' references for GROUNDED claims. Empty array for EXTRAPOLATED/RISKY." },79 "factual_hallucination_probability": { "type": "number", "description": "0.0 to 1.0. GROUNDED ≈ 0, EXTRAPOLATED ≈ 0.1-0.3, RISKY ≈ 0.6-1.0." },80 "rationale": { "type": "string", "description": "One-sentence justification of the status." }LIBRAIN/Program.csGitHub’da aç
1using LIBRAIN.Agents;2using LIBRAIN.Embeddings;3using LIBRAIN.Endpoints;4using LIBRAIN.Models;5using LIBRAIN.Reading;6using LIBRAIN.Storage;7using Microsoft.AspNetCore.Http.Features;8using Microsoft.Extensions.Options;9using Qdrant.Client;10using Scalar.AspNetCore;11 12const long maxUploadBytes = 50_000_000; // 50MB cap on PDF uploads (largest data/papers/ paper is ~9MB)13 14var builder = WebApplication.CreateBuilder(args);15 16builder.WebHost.ConfigureKestrel(options =>17{18 options.Limits.MaxRequestBodySize = maxUploadBytes;19});20 21builder.Services.Configure<FormOptions>(options =>22{23 options.MultipartBodyLengthLimit = maxUploadBytes;24});25 26var applicationInsightsConnectionString = builder.Configuration["ApplicationInsights:ConnectionString"];27if (!string.IsNullOrWhiteSpace(applicationInsightsConnectionString))28{29 builder.Services.AddApplicationInsightsTelemetry();30}31 32builder.Services.AddOpenApi();33 34builder.Services.Configure<AnthropicOptions>(35 builder.Configuration.GetSection(AnthropicOptions.SectionName));36// Fail fast with an actionable message instead of a 502 on the first request.37// Anthropic:ApiKey is deliberately not required here: the OpenAI-only experiments38// (fabrication-delta, provider=openai) run without it; AnthropicChatClient reports39// a missing key when it is first used.40builder.Services.AddOptions<OpenAIOptions>()41 .Bind(builder.Configuration.GetSection(OpenAIOptions.SectionName))42 .Validate(o => !string.IsNullOrWhiteSpace(o.ApiKey),43 "OpenAI:ApiKey is not configured (needed for embeddings). Set it with: dotnet user-secrets set \"OpenAI:ApiKey\" \"sk-...\" --project LIBRAIN")44 .ValidateOnStart();45builder.Services.AddOptions<QdrantOptions>()46 .Bind(builder.Configuration.GetSection(QdrantOptions.SectionName))47 .Validate(o => !string.IsNullOrWhiteSpace(o.Host),48 "Qdrant:Host is not configured. For local Docker use: dotnet user-secrets set \"Qdrant:Host\" \"localhost\" --project LIBRAIN")49 .ValidateOnStart();50builder.Services.Configure<ModelOptions>(51 builder.Configuration.GetSection(ModelOptions.SectionName));52 53// Qdrant.Client uses gRPC (port 6334), not REST (6333). Cloud clusters require https + apiKey;54// local Docker dev uses neither. Empty ApiKey selects local mode automatically.55builder.Services.AddSingleton<QdrantClient>(sp =>56{57 var options = sp.GetRequiredService<IOptions<QdrantOptions>>().Value;58 return string.IsNullOrWhiteSpace(options.ApiKey)59 ? new QdrantClient(options.Host, options.Port)60 : new QdrantClient(61 host: options.Host,62 port: options.Port,63 https: options.UseHttps,64 apiKey: options.ApiKey);65});66 67builder.Services.AddSingleton<AnthropicChatClient>();68builder.Services.AddSingleton<LIBRAIN.Llm.ILlmClient>(sp => sp.GetRequiredService<AnthropicChatClient>());69builder.Services.AddScoped<IEmbeddingClient, OpenAIEmbeddingClient>();70builder.Services.AddScoped<LIBRAIN.Generation.OpenAIChatClient>();71builder.Services.AddScoped<LIBRAIN.Generation.OpenAiDiscoveryAgent>();72// Singleton: stateless apart from its one-time collection setup, which used to race73// when two first requests each ran it from their own scoped instance.74builder.Services.AddSingleton<IPaperStore, QdrantPaperRepository>();75builder.Services.AddScoped<LIBRAIN.Retrieval.TopicRetriever>();76builder.Services.Configure<LIBRAIN.Runs.RunStoreOptions>(builder.Configuration.GetSection(LIBRAIN.Runs.RunStoreOptions.SectionName));77builder.Services.AddSingleton<LIBRAIN.Runs.IRunStore>(sp =>78{79 var path = sp.GetRequiredService<IOptions<LIBRAIN.Runs.RunStoreOptions>>().Value.DatabasePath;80 return new LIBRAIN.Runs.SqliteRunStore(Path.IsPathRooted(path) ? path : Path.Combine(builder.Environment.ContentRootPath, path));.secrets/key.txt
1# Gizli dosyalara baktın. Çoğu kişi bakmaz.2# Bu da senin olsun:3 mainC#★ 1README.mdGitHub



