Skip to content

Commit

Permalink
copy editing the Gemma notebook (#32188)
Browse files Browse the repository at this point in the history
  • Loading branch information
rszper authored Aug 15, 2024
1 parent a2f5ee2 commit 8171e8c
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@
"1. Read the review data from Pub/Sub, the event messaging source. This data contains the chat ID and the chat history as a JSON payload. This payload is processed in the pipeline.\n",
"1. Pass the text from the messages to Gemma with a prompt.\n",
"1. The pipeline requests that the model complete the following two tasks:\n",
" * Attach a sentiment score to the message, by using one of the following three values: `1` for a positive chat, `0` for a neutral chat, and `-1` for a negative chat.\n",
" * Provide a one-sentence summary of the chat.\n",
" * Attach a sentiment score to the message, by using one of the following three values: `1` for a positive chat, `0` for a neutral chat, and `-1` for a negative chat.\n",
" * Provide a one-sentence summary of the chat.\n",
"1. The pipeline branches, depending on the sentiment score:\n",
" * If the score is `1` or `0`, the chat and its summarization are sent to a data analytics system for storage and future analysis.\n",
" * If the score is `-1`, the Gemma model drafts a response. This response and the chat information are sent to an event messaging system that connects the pipeline and other applications. This step allows a person to review the content of the response. "
" * If the score is `1` or `0`, the chat and its summarization are sent to a data analytics system for storage and future analysis.\n",
" * If the score is `-1`, the Gemma model drafts a response. This response and the chat information are sent to an event messaging system that connects the pipeline and other applications. This step allows a person to review the content of the response. "
]
},
{
Expand Down Expand Up @@ -342,7 +342,7 @@
"id": "0gicDesYWdbu"
},
"source": [
"Set pipeline options and provide the input Pub/Sub topic. The options that are commented out enable running the pipeline on Google Cloud Dataflow."
"Set pipeline options and provide the input Pub/Sub topic. The options that are commented out enable running the pipeline on Dataflow."
]
},
{
Expand Down Expand Up @@ -377,7 +377,7 @@
"id": "g8sWSMRmW-Ab"
},
"source": [
"Define a custom model handler that will load the Gemma model and handle inference calls."
"Define a custom model handler that loads the Gemma model and handles inference calls."
]
},
{
Expand Down Expand Up @@ -453,7 +453,7 @@
"id": "cSbAFPXmXPMc"
},
"source": [
"We definte a prompt template to format a given input as well as instruct the model on the task being asked of it. This block also has an example input to the model."
"Define a prompt template. The template formats inputs and instructs the model on the task. This block also contains an example input to the model."
]
},
{
Expand Down Expand Up @@ -493,7 +493,7 @@
"id": "8UFfKvSeYn0b"
},
"source": [
"Define pre and post-processing functions. `CreatePrompt` creates a key-value pair of the chat ID and the formatted prompt. `extract_model_reply` parses the response, extracting the JSON string we requested from the model; however, the LLM is not *guaranteed* to return a JSON-formatted object, so we also reaise an exception if the reply is malformed. This helper is then used in the `SentimentAnalysis` `DoFn` to split out the sentiment score as well as the summary of the text. The sentiment score is then used to tag the output, allowing the pipeline to handle different sentiments in different ways."
"Define pre- and post-processing functions. The `CreatePrompt` class creates a key-value pair that contains the chat ID and the formatted prompt. The `extract_model_reply` function parses the response, extracting the JSON string requested from the model. The LLM is not guaranteed to return a JSON-formatted object. If the reply is malformed, the code produces an exception. This helper is used in the `SentimentAnalysis` class `DoFn` to split out the sentiment score and the summary of the text. The sentiment score is then used to tag the output, allowing the pipeline to handle different sentiments in different ways."
]
},
{
Expand Down Expand Up @@ -559,7 +559,7 @@
"id": "Yj9aQ0q8YLOn"
},
"source": [
"Finally, execute the pipeline using the code below. To use the example chat input created earlier instead of a custom Pub/Sub source, use `chats = p | beam.Create([chat])` instead of the Pub/Sub read."
"To run the pipeline, use the following code. To use the example chat input created previously, instead of a custom Pub/Sub source, use `chats = p | beam.Create([chat])` instead of the Pub/Sub read."
]
},
{
Expand Down

0 comments on commit 8171e8c

Please sign in to comment.