docsenseο
DocSense: An intelligent document assistant powered by Qwen.
Functions
|
|
|
|
|
Classes
|
Main class for document processing and question answering. |
- class DocSense(model_name='Qwen/Qwen2-7B', embedding_model=None, device='cuda', index_path=None, use_gpu_faiss=True)[source]ο
Main class for document processing and question answering.
- Parameters:
- __init__(model_name='Qwen/Qwen2-7B', embedding_model=None, device='cuda', index_path=None, use_gpu_faiss=True)[source]ο
Initialize DocSense instance.
- Parameters:
model_name (
str
) β Name of the Qwen model to useembedding_model (
Optional
[str
]) β Name of the embedding model (defaults to model_name if None)device (
str
) β Device to run the model on (βcudaβ or βcpuβ)index_path (
Optional
[str
]) β Path to store/load the vector index (defaults to ~/.docsense/index)use_gpu_faiss (
bool
) β Whether to use GPU for FAISS operations
- index_documents(doc_path)[source]ο
Index documents from the specified path.
- Parameters:
doc_path (
str
) β Path to the documents directory- Raises:
ValueError β If no documents are found in the specified path
Exception β If there are errors during embedding generation or vector store operations
- Return type:
- ask(question)[source]ο
Answer a question based on the indexed documents.
- Parameters:
question (
str
) β User question- Returns:
answer: Generated response to the question
sources: List of relevant source documents with metadata
metadata: Additional information about prompt and generation config
- Return type:
Dict containing
- Raises:
RuntimeError β If no documents have been indexed yet
Modules
Document indexing and processing module. |
|
Model implementations for DocSense. |