How intellabs/convassist works
Project type and purpose
• ConvAssist is a Python library (not a web app) providing near-real-time text suggestions for users with disabilities.
• It integrates with Intel’s ACAT toolkit and offers demo scripts.
• It combines n-gram models (via Pressagio) and GPT-2 (via PyTorch) to predict next words or full sentence completions.
File structure
• Top-level directories:
• convassist/ – core library modules
• interfaces/ – ACAT integrations and demo applications
• 3rd_party_resources/ – datasets and utilities for building n-gram models
• Key submodules in convassist/:
• combiner/ (merges predictions)
• predictor/ (multiple predictor implementations)
• context_tracker.py (maintains conversation context)
• predictor_registry.py & predictor_activator.py (plugin/registry pattern)
• utilities/ (database connectors, logging, n-gram utilities, singleton)
• Config/build files: pyproject.toml, GitHub workflows, ACAT build scripts.
README for additional insights
• Core predictors: SentenceCompletion, SpellCorrect, CannedPhrases, SmoothedNgram (with GeneralWord & CannedWord specializations)
• Dependencies: Pressagio (n-grams), PyTorch (GPT-2), SQLite for canned-phrase DB.
a. Main components (use block or UML component notation):
1. User Interface Layer
– ACAT Integration (WebSocketHandler, Win32PipeHandler)
– Demo apps (continuous_predict, prompter)
2. Core Library Layer
– ConvAssist API (ConvAssist.py)
– ContextTracker
– PredictorRegistry & PredictorActivator
– Combiner (combiner.py, meritocrity_combiner.py)
3. Predictor Modules (pluggable components)
– SmoothedNgramPredictor
– GeneralWordPredictor
– CannedWordPredictor
– CannedPhrasesPredictor
– SentenceCompletionPredictor (n-gram + GPT-2)
– SpellCorrectPredictor
4. Utilities
– DatabaseUtils (SQLite connector)
– LoggingUtility
– NGramMap & NGramUtil
– Singleton helper
5. External Dependencies & Data
– Pressagio n-gram library
– PyTorch / GPT-2 model
– AAC & PersonaChat datasets (3rd_party_resources)
• UI Layer → ConvAssist API: user keystrokes or context
• ConvAssist API → ContextTracker: update conversation state
• ConvAssist API → PredictorActivator: decide which predictors to invoke
• PredictorActivator → PredictorRegistry: fetch predictor classes
• Predictor modules ↔ Utilities: query n-gram maps, DB for canned phrases, call GPT-2 via PyTorch
• Predictor outputs → Combiner: merge and rank suggestions
• Combiner → ConvAssist API → UI Layer: return final suggestions
c. Architectural patterns & principles:
– Layered architecture (UI, Core, Predictors, Utilities, External)
– Plugin/Registry pattern for predictors (easy extensibility)
– Singleton pattern for shared resources (logger, DB connector)
d. Key technologies & frameworks:
– Python 3.12, Poetry (pyproject.toml)
– Pressagio (n-gram prediction)
– PyTorch for GPT-2 inference
– SQLite for canned-phrase storage
– ACAT messaging handlers (WebSocket, Win32Pipe)
Detail
• Split out each major class or submodule as its own component.
• Storage of n-gram maps and datasets separately.
• Don’t hesitate to show even small utilities if they play a role in prediction or data access.
• Aim for a complete picture of how user input traverses the system, how predictors are invoked, and how suggestions are returned.
• This level of granularity ensures that maintainers and new engineers understand each moving part and how to extend or debug the system.