Instructions to use Navaneeth-14/rag-hackathon-app with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Navaneeth-14/rag-hackathon-app with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: llama cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: llama cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Use Docker
docker model run hf.co/Navaneeth-14/rag-hackathon-app:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use Navaneeth-14/rag-hackathon-app with Ollama:
ollama run hf.co/Navaneeth-14/rag-hackathon-app:Q4_K_M
- Unsloth Studio
How to use Navaneeth-14/rag-hackathon-app with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Navaneeth-14/rag-hackathon-app to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Navaneeth-14/rag-hackathon-app to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Navaneeth-14/rag-hackathon-app to start chatting
- Docker Model Runner
How to use Navaneeth-14/rag-hackathon-app with Docker Model Runner:
docker model run hf.co/Navaneeth-14/rag-hackathon-app:Q4_K_M
- Lemonade
How to use Navaneeth-14/rag-hackathon-app with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Navaneeth-14/rag-hackathon-app:Q4_K_M
Run and chat with the model
lemonade run user.rag-hackathon-app-Q4_K_M
List all available models
lemonade list
- Atomic Chat
| """ | |
| PDF Document Processor Test | |
| Allows you to choose any PDF file and process it with the document processor | |
| """ | |
| import os | |
| import sys | |
| import tkinter as tk | |
| from tkinter import filedialog, messagebox | |
| from pathlib import Path | |
| import tempfile | |
| import shutil | |
| def select_pdf_file(): | |
| """Open file dialog to select a PDF file""" | |
| root = tk.Tk() | |
| root.withdraw() # Hide the main window | |
| file_path = filedialog.askopenfilename( | |
| title="Select a PDF file to process", | |
| filetypes=[("PDF files", "*.pdf"), ("All files", "*.*")] | |
| ) | |
| root.destroy() | |
| return file_path | |
| def process_pdf_with_ocr(pdf_path, use_ocr=False): | |
| """Process a PDF file with optional OCR""" | |
| try: | |
| from document_processer import AdvancedDocumentProcessor | |
| print(f"π Processing PDF: {pdf_path}") | |
| print(f"π File size: {os.path.getsize(pdf_path) / 1024:.1f} KB") | |
| # Initialize processor | |
| processor = AdvancedDocumentProcessor() | |
| # Process the document | |
| chunks = processor.process_document(pdf_path, use_ocr=use_ocr) | |
| return chunks, None | |
| except Exception as e: | |
| return None, str(e) | |
| def display_results(chunks, pdf_path): | |
| """Display processing results""" | |
| print(f"\n{'='*60}") | |
| print("π PROCESSING RESULTS") | |
| print(f"{'='*60}") | |
| print(f"π PDF File: {pdf_path}") | |
| print(f"π Total Chunks: {len(chunks)}") | |
| # Analyze chunks | |
| text_chunks = [c for c in chunks if c.section_type == 'main_text'] | |
| table_chunks = [c for c in chunks if c.section_type == 'table'] | |
| metadata_chunks = [c for c in chunks if c.section_type == 'metadata'] | |
| print(f"π Text Chunks: {len(text_chunks)}") | |
| print(f"π Table Chunks: {len(table_chunks)}") | |
| print(f"π·οΈ Metadata Chunks: {len(metadata_chunks)}") | |
| # Show sample chunks | |
| print(f"\nπ SAMPLE CHUNKS:") | |
| for i, chunk in enumerate(chunks[:5]): # Show first 5 chunks | |
| print(f"\nChunk {i+1}:") | |
| print(f" ID: {chunk.chunk_id}") | |
| print(f" Type: {chunk.section_type}") | |
| print(f" Content Preview: {chunk.content[:150]}...") | |
| if chunk.table_data: | |
| print(f" Table Data: {len(chunk.table_data.get('data', []))} rows") | |
| if len(chunks) > 5: | |
| print(f"\n... and {len(chunks) - 5} more chunks") | |
| # Save results to file | |
| save_results_to_file(chunks, pdf_path) | |
| def save_results_to_file(chunks, pdf_path): | |
| """Save processing results to a text file""" | |
| try: | |
| # Create output filename | |
| pdf_name = Path(pdf_path).stem | |
| output_file = f"{pdf_name}_processed_results.txt" | |
| with open(output_file, 'w', encoding='utf-8') as f: | |
| f.write(f"PDF Processing Results\n") | |
| f.write(f"="*50 + "\n") | |
| f.write(f"Source PDF: {pdf_path}\n") | |
| f.write(f"Total Chunks: {len(chunks)}\n\n") | |
| for i, chunk in enumerate(chunks): | |
| f.write(f"Chunk {i+1}:\n") | |
| f.write(f" ID: {chunk.chunk_id}\n") | |
| f.write(f" Type: {chunk.section_type}\n") | |
| f.write(f" Source: {chunk.source_file}\n") | |
| f.write(f" File Type: {chunk.file_type}\n") | |
| f.write(f" Content:\n{chunk.content}\n") | |
| f.write(f" {'-'*40}\n\n") | |
| print(f"\nπΎ Results saved to: {output_file}") | |
| except Exception as e: | |
| print(f"β οΈ Could not save results to file: {e}") | |
| def analyze_pdf_content(chunks): | |
| """Analyze the content of processed chunks""" | |
| print(f"\nπ CONTENT ANALYSIS") | |
| print(f"{'='*40}") | |
| total_text_length = sum(len(chunk.content) for chunk in chunks) | |
| avg_chunk_size = total_text_length / len(chunks) if chunks else 0 | |
| print(f"π Total Text Length: {total_text_length:,} characters") | |
| print(f"π Average Chunk Size: {avg_chunk_size:.0f} characters") | |
| # Find longest and shortest chunks | |
| if chunks: | |
| longest_chunk = max(chunks, key=lambda x: len(x.content)) | |
| shortest_chunk = min(chunks, key=lambda x: len(x.content)) | |
| print(f"π Longest Chunk: {len(longest_chunk.content)} characters") | |
| print(f"π Shortest Chunk: {len(shortest_chunk.content)} characters") | |
| # Count unique words | |
| all_text = " ".join(chunk.content for chunk in chunks) | |
| unique_words = len(set(all_text.lower().split())) | |
| total_words = len(all_text.split()) | |
| print(f"π Total Words: {total_words:,}") | |
| print(f"π Unique Words: {unique_words:,}") | |
| def main(): | |
| """Main function to run the PDF processor test""" | |
| print("π PDF Document Processor Test") | |
| print("="*50) | |
| print("This tool allows you to process any PDF file by specifying its path.") | |
| print("You can choose whether to use OCR for better text extraction.") | |
| print() | |
| # Check if document processor is available | |
| try: | |
| from document_processer import AdvancedDocumentProcessor | |
| print("β Document processor loaded successfully") | |
| except ImportError as e: | |
| print(f"β Error loading document processor: {e}") | |
| print("π‘ Make sure document_processer.py is in the same directory") | |
| return | |
| # Get PDF file path | |
| print("\nπ Enter the path to your PDF file:") | |
| print(" Examples:") | |
| print(" - C:\\Users\\YourName\\Documents\\document.pdf") | |
| print(" - /home/username/documents/document.pdf") | |
| print(" - ./local_file.pdf") | |
| print(" - Or press Enter to use file dialog") | |
| pdf_path = input("PDF file path: ").strip() | |
| # If no path provided, use file dialog | |
| if not pdf_path: | |
| print("\nπ Opening file dialog...") | |
| pdf_path = select_pdf_file() | |
| if not pdf_path: | |
| print("β No file selected. Exiting.") | |
| return | |
| # Expand relative paths and resolve to absolute path | |
| pdf_path = os.path.abspath(os.path.expanduser(pdf_path)) | |
| if not os.path.exists(pdf_path): | |
| print(f"β File not found: {pdf_path}") | |
| print("π‘ Please check the file path and try again.") | |
| return | |
| # Check if it's actually a PDF file | |
| if not pdf_path.lower().endswith('.pdf'): | |
| print(f"β οΈ Warning: File doesn't have .pdf extension: {pdf_path}") | |
| proceed = input("Continue anyway? (y/n): ").lower().strip() | |
| if proceed not in ['y', 'yes']: | |
| print("β Exiting.") | |
| return | |
| print(f"β Found file: {pdf_path}") | |
| print(f"π File size: {os.path.getsize(pdf_path) / 1024:.1f} KB") | |
| # Ask about OCR | |
| print("\nπ€ Do you want to use OCR for better text extraction?") | |
| print(" OCR is useful for scanned PDFs or PDFs with images") | |
| print(" OCR takes longer but provides better results for image-based PDFs") | |
| use_ocr = input("Use OCR? (y/n): ").lower().strip() in ['y', 'yes'] | |
| if use_ocr: | |
| print("π Will use OCR for text extraction") | |
| else: | |
| print("π Will use standard text extraction") | |
| # Process the PDF | |
| print(f"\nπ Processing PDF...") | |
| chunks, error = process_pdf_with_ocr(pdf_path, use_ocr) | |
| if error: | |
| print(f"β Error processing PDF: {error}") | |
| print("\nπ‘ Troubleshooting tips:") | |
| print("1. Make sure the PDF file is not corrupted") | |
| print("2. Try without OCR if the PDF has text") | |
| print("3. Check if all dependencies are installed") | |
| print("4. Verify the file path is correct") | |
| return | |
| if not chunks: | |
| print("β No chunks were extracted from the PDF") | |
| print("π‘ This might be because:") | |
| print(" - The PDF is password protected") | |
| print(" - The PDF contains only images") | |
| print(" - The PDF is corrupted") | |
| return | |
| # Display results | |
| display_results(chunks, pdf_path) | |
| # Analyze content | |
| analyze_pdf_content(chunks) | |
| print(f"\nπ PDF processing completed successfully!") | |
| print(f"π Processed: {pdf_path}") | |
| print(f"π Extracted: {len(chunks)} chunks") | |
| def batch_process_pdfs(): | |
| """Process multiple PDF files in a directory""" | |
| print("π Batch PDF Processing") | |
| print("="*40) | |
| # Select directory | |
| root = tk.Tk() | |
| root.withdraw() | |
| directory = filedialog.askdirectory(title="Select directory containing PDF files") | |
| root.destroy() | |
| if not directory: | |
| print("β No directory selected") | |
| return | |
| # Find PDF files | |
| pdf_files = list(Path(directory).glob("*.pdf")) | |
| if not pdf_files: | |
| print("β No PDF files found in the selected directory") | |
| return | |
| print(f"π Found {len(pdf_files)} PDF files in {directory}") | |
| # Process each PDF | |
| results = {} | |
| for pdf_file in pdf_files: | |
| print(f"\nπ Processing: {pdf_file.name}") | |
| chunks, error = process_pdf_with_ocr(str(pdf_file), use_ocr=False) | |
| if error: | |
| print(f"β Error: {error}") | |
| results[pdf_file.name] = "ERROR" | |
| else: | |
| print(f"β Processed: {len(chunks)} chunks") | |
| results[pdf_file.name] = len(chunks) | |
| # Summary | |
| print(f"\nπ BATCH PROCESSING SUMMARY") | |
| print(f"{'='*40}") | |
| successful = sum(1 for result in results.values() if isinstance(result, int)) | |
| total = len(results) | |
| for filename, result in results.items(): | |
| status = f"{result} chunks" if isinstance(result, int) else result | |
| print(f"{filename}: {status}") | |
| print(f"\nβ Successfully processed: {successful}/{total} files") | |
| def process_from_command_line(): | |
| """Process PDF from command line arguments""" | |
| import sys | |
| if len(sys.argv) < 2: | |
| print("β Usage: python test_pdf_processor.py <pdf_file_path> [--ocr]") | |
| print(" Example: python test_pdf_processor.py C:\\path\\to\\document.pdf --ocr") | |
| return | |
| pdf_path = sys.argv[1] | |
| use_ocr = "--ocr" in sys.argv | |
| # Expand relative paths and resolve to absolute path | |
| pdf_path = os.path.abspath(os.path.expanduser(pdf_path)) | |
| if not os.path.exists(pdf_path): | |
| print(f"β File not found: {pdf_path}") | |
| return | |
| print(f"π Processing PDF from command line: {pdf_path}") | |
| print(f"π OCR enabled: {use_ocr}") | |
| # Process the PDF | |
| chunks, error = process_pdf_with_ocr(pdf_path, use_ocr) | |
| if error: | |
| print(f"β Error processing PDF: {error}") | |
| return | |
| if not chunks: | |
| print("β No chunks were extracted from the PDF") | |
| return | |
| # Display results | |
| display_results(chunks, pdf_path) | |
| analyze_pdf_content(chunks) | |
| print(f"\nπ PDF processing completed successfully!") | |
| if __name__ == "__main__": | |
| # Check if command line arguments are provided | |
| if len(sys.argv) > 1 and not sys.argv[1].startswith("--"): | |
| process_from_command_line() | |
| else: | |
| print("Choose an option:") | |
| print("1. Process a single PDF file") | |
| print("2. Batch process all PDFs in a directory") | |
| print("3. Process from command line (usage: python test_pdf_processor.py <pdf_path> [--ocr])") | |
| choice = input("Enter choice (1, 2, or 3): ").strip() | |
| if choice == "1": | |
| main() | |
| elif choice == "2": | |
| batch_process_pdfs() | |
| elif choice == "3": | |
| print("\nCommand line usage:") | |
| print("python test_pdf_processor.py <pdf_file_path> [--ocr]") | |
| print("\nExamples:") | |
| print("python test_pdf_processor.py C:\\path\\to\\document.pdf") | |
| print("python test_pdf_processor.py /home/user/document.pdf --ocr") | |
| print("python test_pdf_processor.py ./local_file.pdf") | |
| else: | |
| print("β Invalid choice. Exiting.") |