Trans Advice Agent

Overview:

TransAdviceAgent is an experimental tool designed to answer transgender-related questions by compiling and synthesizing community knowledge from forums and online discussions. The focus is on questions that require community guidance rather than simple factual answers, as there are very few trans-related topics backed by comprehensive research.

Many medical questions and practical recommendations are best answered by community forums where people share real experiences. This project aims to make that collective knowledge more accessible by using advanced natural language processing to search, summarize, and synthesize information from these community sources.

The system uses query enhancement with synonyms to improve search relevance, retrieval of diverse sources using embedding similarity, and hierarchical summarization to provide comprehensive answers grounded in community experiences.

Please note that this is an amateur project and not a professional medical resource. Answers are limited to the community documents included in the system — they may be incomplete, biased, or outdated. Always consult licensed healthcare providers and multiple sources when making decisions about your care.

Privacy Notice: This system uses LangSmith for monitoring and logging all interactions, including your questions and the generated responses. Please do not input sensitive personal information, medical details, or anything you would not want logged for analysis and improvement purposes.

Currently, the system draws primarily from Wikipedia and Reddit. The database will be expanded in future iterations to include additional trans community forums, official resources, and curated documents. If you know of communities or resources that should be included, please let me know!

If you have questions, feedback, or suggestions for improving this project, please reach out to me at sam@walking-stick.com.

Try It Out

How the Pipeline Works

TransAdviceAgent processes user questions through a sophisticated multi-stage pipeline designed to surface relevant community knowledge and provide comprehensive, well-sourced answers. The system emphasizes finding diverse perspectives and remains fully grounded in community-sourced documents.

  1. Query Enhancement
    The user's original question is enhanced using Claude Haiku to add relevant synonyms and alternative phrasings. This critical step ensures that when the embedding model searches for similar content, it finds all relevant sources rather than missing documents due to vocabulary differences. The original query is preserved for the final answering stage.
  2. Embedding-Based Retrieval
    Community documents are pre-chunked and stored in a FAISS vector database with SQLite metadata storage. The enhanced query is embedded using the all-MiniLM-L6-v2 model and used to find semantically similar document chunks. Maximal Marginal Relevance (MMR) is used to ensure diverse perspectives and avoid redundant sources.
  3. Parallel Batch Summarization
    Retrieved document chunks are processed in parallel batches of 10 using Claude Haiku. Each batch is summarized independently to capture the key information, experiences, and perspectives while preserving important details like dates, outcomes, and any conflicting viewpoints.
  4. Hierarchical Summary Combination
    All batch summaries are combined by the LLM into a single, comprehensive summary that aggregates patterns, highlights frequently mentioned information, and preserves the diversity of community experiences and opinions.
  5. Final Answer Generation
    Using the original user question and the combined summary, Claude Haiku generates the final answer. The response is designed to be comprehensive, balanced, and clearly grounded in the community sources, including both positive and negative experiences where present.

You can view the full source code and contribute here: github.com/SamPease/TransAdviceAgent

Tech Stack:

  • Python — core programming language for the entire pipeline
  • FastAPI — backend web framework for the API server
  • Claude Haiku — language model for query enhancement, summarization, and answer generation
  • all-MiniLM-L6-v2 — embedding model for semantic similarity search, used both locally for database creation and via Hugging Face for inference
  • LangChain/LangSmith — orchestrates the entire pipeline and provides monitoring/logging of all interactions
  • FAISS — vector database for efficient similarity search with MMR (Maximal Marginal Relevance). Uses FAISS IVFPQ (inverted file + product quantization) to reduce memory usage and enable larger database scaling by avoiding the need to load the entire embedding index into memory at runtime.
  • SQLite — lightweight database for document metadata and text storage
  • Hugging Face — hosts the pre-built FAISS index and SQLite database files created offline, and provides inference API for all-MiniLM-L6-v2 when running the web app
  • Render — cloud hosting platform for the backend web application
  • GitHub Pages — static frontend hosting for this interface
  • GitHub — version control and open source code hosting (view code)

Limitations & Future Work

TransAdviceAgent is an experimental, hobby project and has several limitations that users should be aware of:

  • Document Coverage: The system can only provide answers based on the documents in its database. If a topic, clinician, or procedure is not well-represented, the answer may be incomplete or indicate insufficient evidence.
  • Community Bias: Retrieved documents reflect the perspectives of those who chose to share their experiences. They may not represent the full range of outcomes or experiences for a given healthcare provider or procedure.
  • Latency: Because the system uses multiple LLM calls for summarization, synthesis, and answering, responses may be slow. Additionally, the biggest barrier to response time is that the backend runs on a free hosting tier that spins down due to inactivity and can take up to two minutes to spin back up.
  • Abbreviation Expansion: Automatic expansion of initials to full clinician names is based on a curated mapping and context. Unmapped or ambiguous initials may lead to missed documents or incorrect matches.
  • No Medical Advice: The system summarizes community-sourced information and is not a substitute for professional medical guidance. Users should consult licensed providers for personal healthcare decisions.

Future Work:

  • Expand data sources beyond Reddit to include additional trans community forums, resources, and documentation.
  • Improve retrieval quality with additional techniques, such as sparse keyword search or hybrid dense-sparse approaches.
  • Incorporate provenance tracking for each fact in the final answer, showing exactly which documents contributed to which statements.
  • Optimize latency and scalability, including batching strategies and lighter-weight summarization models for faster responses.
  • Enhance abbreviation and synonym expansion using automated context-aware methods to reduce manual mapping and increase accuracy.