CoolFace
Apppublic

Latoff/GR15ALF447

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

๐Ÿค– Kawasaki Robot Expert - RAG System

An intelligent AI assistant specialized in Kawasaki industrial robotics documentation and AS programming language. Built with hybrid vector search and advanced RAG (Retrieval-Augmented Generation) techniques.

๐ŸŒŸ Features

๐Ÿง  Intelligent Document Processing

  • โ€”Hybrid Vector Search: Combines ChromaDB semantic search + BM25 keyword matching
  • โ€”Smart Chunking: AS code-aware chunking for programming examples
  • โ€”Context Expansion: Automatically retrieves neighboring document sections
  • โ€”Multi-format Support: PDF, TXT, and AS code files

๐ŸŽฏ Specialized Knowledge Domains

  • โ€”AS Programming: Syntax, functions, procedures, motion commands
  • โ€”I/O Handling: Signal management and external equipment integration
  • โ€”Safety Procedures: Emergency protocols and safety guidelines
  • โ€”Troubleshooting: Diagnostic procedures and error resolution
  • โ€”Technical Specifications: Hardware specs and installation guides

๐Ÿ“Š Advanced Visualization

  • โ€”t-SNE Embedding Clusters: Visualize document relationships
  • โ€”Interactive Document Explorer: Browse document sections
  • โ€”Debug Interface: View RAG prompts and search results
  • โ€”Real-time Statistics: Monitor database content

๐Ÿ”ง Developer Features

  • โ€”Modular Architecture: Separate vector store and agent components
  • โ€”Debug Tools: Comprehensive logging and search debugging
  • โ€”Flexible Configuration: Easy model and parameter adjustment
  • โ€”Extensible Design: Add new document types and LLM backends

๐Ÿš€ Quick Start

1. Environment Setup

bash
# Set your Fireworks AI API key
export FIREWORKS_API_KEY="your_fireworks_api_key_here"

2. Install Dependencies

bash
uv sync
# or
pip install -r requirements.txt

3. Run the Application

bash
uv run kawasaki-expert
# or
python app/main.py

4. Upload Documents

  • โ€”Navigate to the "โž• Add Document" tab
  • โ€”Upload your robotics documentation (PDF, TXT, AS files)
  • โ€”Select appropriate document type
  • โ€”System automatically indexes and processes content

๐Ÿ“ Document Organization

The system organizes documents into specialized categories:

  • โ€”`Practical_Recomendations/` - Procedures, I/O specifications, teaching methods
  • โ€”`Programming_Language_and_Examples/` - AS language reference, syntax guides
  • โ€”`Reference/` - Technical handbooks, specifications, general robotics
  • โ€”`Code_Examples/` - AS programming examples, function libraries
  • โ€”`General_Robotics/` - General robotics knowledge and principles

๐ŸŽฎ Usage Examples

Basic Queries

"What are the values for external equipment I/O?"
"How do I program a pick and place operation?"
"What are the safety procedures for robot maintenance?"

AS Programming

"Show me how to implement error handling in AS?"
"What's the syntax for motion commands?"
"Give me an example of I/O signal management"

Technical Troubleshooting

"How do I troubleshoot communication errors?"
"What are the calibration procedures for a new robot?"
"Explain the tip compensation reset procedure"

๐Ÿ—๏ธ Architecture

Hybrid Vector Store

  • โ€”ChromaDB: Persistent vector database with cosine similarity
  • โ€”SentenceTransformers: all-MiniLM-L6-v2 for embeddings
  • โ€”BM25: Keyword-based retrieval for technical terms
  • โ€”Smart Chunking: Content-aware document splitting

Agent System

  • โ€”Fireworks AI: Qwen 2.5 72B model for responses
  • โ€”Context Expansion: Retrieves neighboring document sections
  • โ€”Source Citation: Automatic reference to specific documents/sections
  • โ€”Memory Management: Conversation history with debug info

Web Interface

  • โ€”Gradio: Interactive chat interface
  • โ€”Real-time Visualization: t-SNE embedding clusters
  • โ€”Debug Tools: Prompt inspection and search result analysis
  • โ€”Document Management: Upload and browse capabilities

๐Ÿ”ฌ Technical Details

Chunking Strategies

  • โ€”Code Files: 3000 chars, AS-aware separators (END FUNCTION, END PROCEDURE)
  • โ€”Documentation: 6000 chars, semantic separators for complete procedures
  • โ€”Context Expansion: Retrieves 5 neighboring sections with proximity scoring

Search Algorithm

  1. 1.Semantic Search: Vector similarity using embeddings
  2. 2.Keyword Search: BM25 scoring for technical terms
  3. 3.Hybrid Scoring: Weighted combination (70% semantic, 30% keyword)
  4. 4.Context Expansion: Add neighboring chunks from top results
  5. 5.Ranking: Sort by combined relevance score

Performance Optimizations

  • โ€”Intelligent Sampling: Max 2000 points for visualization
  • โ€”Efficient Indexing: Incremental BM25 rebuilding
  • โ€”Memory Management: Conversation history pruning
  • โ€”Caching: Persistent vector storage

๐Ÿ› ๏ธ Development

Project Structure

app/
โ”œโ”€โ”€ vector_store.py      # Hybrid vector search system
โ”œโ”€โ”€ robot_agent.py       # AI agent and chat interface
โ”œโ”€โ”€ ui_gradio.py         # Web interface components
โ”œโ”€โ”€ main.py             # Application entry point
โ””โ”€โ”€ agent_kawasaki.py   # Legacy compatibility layer

Adding New Document Types

  1. 1.Create folder in app/data/YourDocumentType/
  2. 2.Add documents (PDF, TXT, AS files)
  3. 3.System automatically detects and processes

Extending LLM Support

Modify robot_agent.py to support different models:

python
self.current_model = "your_preferred_model"

๐Ÿ“Š Performance Metrics

  • โ€”Database Size: Supports 3000+ document chunks
  • โ€”Search Speed: Sub-second retrieval for most queries
  • โ€”Context Size: Up to 16 expanded sections per query
  • โ€”Visualization: Handles 2000+ points with t-SNE
  • โ€”Memory: Efficient conversation history management

๐Ÿค Contributing

  1. 1.Fork the repository
  2. 2.Create a feature branch
  3. 3.Add your improvements
  4. 4.Test with robotics documentation
  5. 5.Submit a pull request

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ™ Acknowledgments

  • โ€”Kawasaki Robotics for comprehensive technical documentation
  • โ€”ChromaDB for vector storage capabilities
  • โ€”Fireworks AI for powerful language model inference
  • โ€”Gradio for intuitive web interface
  • โ€”Sentence Transformers for semantic embeddings

Built for robotics engineers, by robotics engineers. Making technical documentation instantly accessible through AI.