docsense

DocSense: An intelligent document assistant powered by Qwen.

Functions

ask_question(question,Β **kwargs)

create_index(doc_path,Β **kwargs)

get_docsense(**kwargs)

Classes

DocSense([model_name,Β embedding_model,Β ...])

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:
classmethod get_instance(**kwargs)[source]
__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 use

  • embedding_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:

None

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

get_docsense(**kwargs)[source]
Return type:

DocSense

create_index(doc_path, **kwargs)[source]
Parameters:

doc_path (str)

Return type:

None

ask_question(question, **kwargs)[source]
Parameters:

question (str)

Return type:

Dict[str, Any]

Modules

cli

indexer

Document indexing and processing module.

models

Model implementations for DocSense.