Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.ai.rag #158

Open
hemanth opened this issue Jul 10, 2024 · 4 comments
Open

window.ai.rag #158

hemanth opened this issue Jul 10, 2024 · 4 comments

Comments

@hemanth
Copy link

hemanth commented Jul 10, 2024

The window.ai.rag API enables web applications to perform Retrieval-Augmented Generation (RAG) directly in the browser. RAG combines the power of large language models with the ability to retrieve and incorporate relevant information from a knowledge base.

This API is particularly useful for:

  1. Question-answering systems that need access to up-to-date or specialized information
  2. Content generation tools that require factual accuracy and domain-specific knowledge
  3. Chatbots or virtual assistants that need to provide informative responses based on a specific corpus of data

By implementing RAG in the browser, applications can:

  1. Provide more accurate and contextually relevant responses
  2. Reduce the load on server-side infrastructure
  3. Offer personalized experiences based on user-specific data

More use-cases:

  1. Information Retrieval and Synthesis
  2. Personalized Content Generation
  3. Knowledge Management and Curation
  4. Contextual Assistance
  5. Decision Support Systems
  6. Creative Augmentation
  7. Real-time Information Processing
  8. Predictive Analytics
  9. Interactive Learning and Training
  10. Data Validation and Enrichment
  11. Augmented Communication
  12. Semantic Analysis and Understanding

API:

interface RAGOptions {
  model: string; // Identifier for the base language model
  knowledgeBase: KnowledgeBase;
  retrievalOptions?: RetrievalOptions;
  generationOptions?: GenerationOptions;
}

interface KnowledgeBase {
  type: 'vector' | 'inverted-index' | 'hybrid';
  data: ArrayBuffer | string[]; // Depending on the type
}

interface RetrievalOptions {
  topK?: number; // Number of documents to retrieve
  similarityThreshold?: number;
}

interface GenerationOptions {
  maxTokens?: number;
  temperature?: number;
}

interface RAGResult {
  generatedText: string;
  retrievedDocuments: string[];
  confidence: number;
}

interface WindowAI {
  rag: {
    query(input: string, options: RAGOptions): Promise<RAGResult>;
    updateKnowledgeBase(newData: ArrayBuffer | string[]): Promise<void>;
  };
}

interface Window {
  ai: WindowAI;
}
const result = await window.ai.rag.query(question, ragOptions);
@yoavweiss
Copy link
Collaborator

Hey @hemanth!! I think it might be good to have a single proposal for the various related LLM things. It might also be best to start with a focus on the use cases you're setting out to solve, rather than specific API shapes.

@hemanth
Copy link
Author

hemanth commented Jul 10, 2024

Hello @yoavweiss I briefly touched upon the use-cases, update them with more.

The window.ai.rag would essentially implement a generic RAG (Retrieval-Augmented Generation) function that takes an input and retrieves a set of relevant or supporting documents based on a given source.

single proposal for the various related LLM things

I would love too, you suggest we combine all of #160 #159 #158 into a single proposal?

@petamoriken
Copy link

IMHO, .ai namespace is better in navigator than window. According to the TAG review, the Web Translation API should not be part of the .ai namespace (w3ctag/design-reviews#948 (comment)), so it could still be changed to navigator. How about that?

@hemanth
Copy link
Author

hemanth commented Aug 20, 2024

Name spaces should be function-led rather than technology-used-to-deliver-the-function-led.

The use of a .ai namespace is intentional, reflecting the API's focus on AI technology.
This explicit naming clarifies its purpose and capabilities, distinguishing it from traditional services in a multi-functional environment. Additionally, the .ai namespace is gaining recognition as the standard for AI-related technologies, enhancing clarity for end users.

Would you be suggesting the use of window.navigator.ai?

I would appreciate your insights on any potential side effects of utilizing the .ai namespace on window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants