{"id":19747979,"url":"https://github.com/tensorchord/qtext","last_synced_at":"2025-04-30T08:33:01.929Z","repository":{"id":229965604,"uuid":"775791706","full_name":"tensorchord/qtext","owner":"tensorchord","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-11T07:28:16.000Z","size":196,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-11T08:55:40.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tensorchord.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-22T03:37:42.000Z","updated_at":"2024-04-11T08:55:40.354Z","dependencies_parsed_at":"2024-04-08T08:46:16.439Z","dependency_job_id":"22ce41ef-53b3-46cd-8b6a-7977a37d5f53","html_url":"https://github.com/tensorchord/qtext","commit_stats":null,"previous_names":["tensorchord/qtext"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorchord%2Fqtext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorchord%2Fqtext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorchord%2Fqtext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorchord%2Fqtext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorchord","download_url":"https://codeload.github.com/tensorchord/qtext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224203380,"owners_count":17272939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T02:19:41.784Z","updated_at":"2024-11-12T02:19:42.319Z","avatar_url":"https://github.com/tensorchord.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QText\n\n[![Python Check](https://github.com/tensorchord/qtext/actions/workflows/check.yml/badge.svg)](https://github.com/tensorchord/qtext/actions/workflows/check.yml)\n\u003ca href=\"https://discord.gg/KqswhpVgdU\"\u003e\u003cimg alt=\"discord invitation link\" src=\"https://dcbadge.vercel.app/api/server/KqswhpVgdU?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/TensorChord\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/tensorchord?style=social\" alt=\"trackgit-views\" /\u003e\u003c/a\u003e\n\nQText is a microservices framework for building the RAG pipeline, or semantic search engine on top of Postgres. It provides a simple API to add, query, and highlight the text in your existing database.\n\nThe main features include:\n\n- Full-text search with Postgres GIN index.\n- Vector and sparse search with [pgvecto.rs](https://github.com/tensorchord/pgvecto.rs)\n- Reranking with cross-encoder model, cohere reranking API, or other methods.\n- Semantic highlight\n\nBesides this, qtext also provides a dashboard to visualize the vector search, sparse vector search, full text search, and reranking results.\n\n[![asciicast](https://asciinema.org/a/653540.svg)](https://asciinema.org/a/653540)\n\n## Design goals\n\n- **Simple**: easy to deploy and use.\n- **Customizable**: can be integrated into your existing databases.\n- **Extensible**: can be extended with new features.\n\n## How to use\n\nTo start all the services with [docker compose](https://docs.docker.com/compose/):\n\n```bash\ndocker compose -f docker/compose.yaml up -d server\n```\n\nSome of the dependent services can be opt-out:\n- `emb`: used to generate embedding for query and documents\n- `sparse`: used to generate sparse embedding for query and documents (this requires a HuggingFace token that signed the agreement for [prithivida/Splade_PP_en_v1](https://huggingface.co/prithivida/Splade_PP_en_v1))\n- `highlight`: used to provide the semantic highlight feature\n- `encoder`: rerank with cross-encoder model, you can choose other methods or other online services\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./docs/images/arch.svg\" alt=\"arch\" width=\"500px\"\u003e\n\u003c/div\u003e\n\nFor the client example, check:\n- [test.py](./test.py): simple demo.\n- [test_cohere_wiki.py](./test_cohere_wiki.py): a Wikipedia dataset with Cohere embedding.\n\n## API\n\nWe provide a simple sync/async [client](./qtext/client.py). You can also refer to the OpenAPI and build your own client.\n\n- `/api/namespace` POST: create a new namespace and configure the index\n- `/api/doc` POST: add a new doc\n- `/api/query` POST: query the docs\n- `/api/highlight` POST: semantic highlight\n- `/metrics` GET: open metrics\n\nCheck the [OpenAPI documentation](http://127.0.0.1:8000/openapi/redoc) for more information (this requires the qtext service).\n\n## Terminal UI\n\nWe provide a simple terminal UI powered by [Textual](https://github.com/textualize/textual) for you to interact with the service.\n\n```bash\npip install textual\n# need to run the qtext service first\npython tui/main.py $QTEXT_PORT\n```\n\n## Configurations\n\nCheck the [config.py](./qtext/config.py) for more detail. It will read the `$HOME/.config/qtext/config.json` if this file exists.\n\n## Integrate to the RAG pipeline\n\nThis project has most of the components you need for the RAG except for the last LLM generation step. You can send the retrieval + reranked docs to any LLM providers to get the final result.\n\n## Customize the table schema\n\n\u003e [!NOTE]\n\u003e If you already have the table in Postgres, you will be responsible for the text-indexing and vector-indexing part.\n\n1. Define a `dataclass` that includes the **necessary** columns as class attributes\n   - annotate the `primary_key`, `text_index`, `vector_index`, `sparse_index` with metadata (not all of them are required, only the necessary ones)\n   - attributes without default value or default factory is treated as required when you add new docs\n2. Implement the `to_record` and `from_record` methods to be used in the reranking stage\n3. Change the `config.vector_store.schema` to the class you have defined\n\nCheck the [schema.py](/qtext/schema.py) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorchord%2Fqtext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorchord%2Fqtext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorchord%2Fqtext/lists"}