שליפה ופלט יצירה של Vertex AI RAG Engine

בדף הזה מוסבר על כל שדה בפלט של Vertex AI RAG Engine.

retrieveContexts

בקטע הזה מתואר כל שדה שמוגדר ב-retrieveContexts API, ומוצגות דוגמאות לשימוש בשדות בקוד לדוגמה.

שדות

שם השדה תיאור
source_uri קובץ המקור המקורי לפני הייבוא שלו ל-RAG. אם הקובץ מיובא מ-Cloud Storage או מ-Google Drive, ‏ source_uri הוא ה-URI המקורי של הקובץ ב-Cloud Storage או ב-Drive. אם הקובץ הועלה, source_uri הוא השם לתצוגה של הקובץ.
source_display_name השם המוצג של הקובץ.
text חלק הטקסט שרלוונטי לשאילתה.
score הדמיון או המרחק בין השאילתה לבין קטע הטקסט. מידת הדמיון או המרחק תלויה בvectorDB שתבחרו. במקרה של ragManagedDB, הציון הוא COSINE_DISTANCE.

פלט לדוגמה

בדוגמת הקוד הזו מוצג שימוש בשדות כדי ליצור פלט לדוגמה.

contexts {
    source_uri: "gs://sample_folder/hello_world.txt"
    source_display_name: "hello_world.txt"
    text: "Hello World!"
    score: 0.60545359030757784
  }

generateContent

רוב השדות שמוגדרים ב-generateContent API מופיעים בגוף התשובה.

שדות

בקטע הזה מתואר כל שדה שמוגדר בחלק grounding_metadata של generateContent API, ונעשה שימוש בשדות בקוד לדוגמה.

שם השדה תיאור
text התשובה שנוצרה על ידי Gemini.
grounding_chunks החלקים שמוחזרים על ידי Vertex AI RAG Engine.
retrieved_context שדה חוזר שיכול להכיל אפס או יותר נתונים שמשמשים כבסיס לתוכן שנוצר.
  • uri
  • המיקום הזה מציין את המקום שבו הנתונים מאוחסנים במקור.source_uri
  • title
  • source_display_name הוא שם הקובץ או השם המוצג של הקובץ המקורי.
  • text
  • החלק הזה של הטקסט משמש כהקשר לתשובה של Gemini.
grounding_supports הקשר בין התוכן שנוצר לבין נתחי ההארקה. זהו שדה חוזר. בכל שדה grounding_supports מוצג הקשר בין פלח טקסט אחד של ההקשר שנוצר לבין נתח טקסט אחד או יותר שאוחזר באמצעות RAG.
segment פלח הטקסט המבוסס של הטקסט שנוצר.
  • start_index
  • האינדקס הראשון של הטקסט המבוסס. אם התג start_index חסר, הערך של התג start_index הוא 0.
  • end_index
  • האינדקס האחרון של הטקסט המבוסס.
  • text
  • הטקסט המבוסס.
grounding_chunk_indices החלק שמשמש להארקה של פלח הטקסט. יכול להיות שיש יותר מחלק אחד שמשמש להארקת הטקסט. האינדקס מתחיל מ-0, שמייצג את החלק הראשון בשדה grounding_chunks. הקרקע נמצאת בכל הצ'אנק. לא מצוין החלק של הנתח שעליו מבוססת התשובה.
confidence_scores הציון שמשמש להצגת הטקסט בחלק נתון. הציון הכי גבוה שאפשר לקבל הוא 1, וככל שהציון גבוה יותר, כך רמת הסמך גבוהה יותר. כל ציון תואם לכל grounding_chunk_indices. רק נתחים עם ציון מהימנות של לפחות 0.6 נכללים בפלט.

פלט לדוגמה

בדוגמת הקוד הזו מוצג שימוש בשדות כדי ליצור פלט לדוגמה.

candidates {
  content {
    role: "model"
    parts {
      text: "The rectangle is red and the background is white. The rectangle appears to be on some type of document editing software. \n"
    }
  }
  grounding_metadata {
    grounding_chunks {
      retrieved_context {
        uri: "a.txt"
        title: "a.txt"
        text: "Okay ,  I  see  a  red  rectangle  on  a  white  background .  It looks like it\'s on some sort of document editing software. It has those small squares and circles around it, indicating that it\'s a selected object ."
      }
    }
    grounding_chunks {
      retrieved_context {
        uri: "b.txt"
        title: "b.txt"
        text: "The  video  is  identical  to  the  last  time  I  described  it .  It shows a blue rectangle on a white background."
      }
    }
    grounding_chunks {
      retrieved_context {
        uri: "c.txt"
        title: "c.txt"
        text: "Okay ,  I  remember  the  rectangle  was  blue  in  the  past  session . Now it is red.\n The  red  rectangle  is  still  there .  It \' s  still  in  the same position on the white background, with the same handles around it. Nothing new is visible since last time.\n You \' re  welcome .  The  red  rectangle  is  still  the  only  thing visible."
      }
    }
    grounding_supports {
      segment {
        end_index: 49
        text: "The rectangle is red and the background is white."
      }
      grounding_chunk_indices: 2
      grounding_chunk_indices: 0
      confidence_scores: 0.958192229
      confidence_scores: 0.992316723
    }
    grounding_supports {
      segment {
        start_index: 50
        end_index: 120
        text: "The rectangle appears to be on some type of document editing software."
      }
      grounding_chunk_indices: 0
      confidence_scores: 0.98374176
    }
  }
}

המאמרים הבאים