Struct rust_bert::pipelines::conversation::ConversationModel [−][src]
pub struct ConversationModel { /* fields omitted */ }Expand description
Conversation model
Processes a ConversationManager and generate system responses for active conversations.
Implementations
pub fn new(
conversation_config: ConversationConfig
) -> Result<ConversationModel, RustBertError>
pub fn new(
conversation_config: ConversationConfig
) -> Result<ConversationModel, RustBertError>
Build a new ConversationModel
Arguments
conversation_config-ConversationConfigobject containing the resource references (model, vocabulary, configuration), conversation options and device placement (CPU/GPU)
Example
use rust_bert::pipelines::conversation::ConversationModel;
let conversation_model = ConversationModel::new(Default::default())?;pub fn generate_responses<'a>(
&self,
conversation_manager: &'a mut ConversationManager
) -> HashMap<&'a Uuid, &'a str>
pub fn generate_responses<'a>(
&self,
conversation_manager: &'a mut ConversationManager
) -> HashMap<&'a Uuid, &'a str>
Perform a multi-turn conversation based on user input
Arguments
conversation_manager-&mut ConversationManagerConversation manager keeping track of active conversations
Returns
HashMap<&Uuid, &str>Responses from the model for each active conversation, referenced by Uuid
Example
use rust_bert::pipelines::conversation::{ConversationManager, ConversationModel};
use rust_bert::pipelines::generation_utils::LanguageGenerator;
let model = ConversationModel::new(Default::default())?;
let mut conversation_manager = ConversationManager::new();
conversation_manager.create("Hello, how are you?");
let output = model.generate_responses(&mut conversation_manager);Encodes prompts into Vectors of indices to be processed by the model. This method may be used to initialize the history of a conversation with a prior state.
Example:
use rust_bert::pipelines::conversation::{ConversationManager, ConversationModel};
use rust_bert::pipelines::generation_utils::LanguageGenerator;
let model = ConversationModel::new(Default::default())?;
let history = [
"Going to the movies tonight - any suggestions?",
"The Big Lebowski",
"Is it an action movie?",
];
let encoded_history = model.encode_prompts(&history);Auto Trait Implementations
impl RefUnwindSafe for ConversationModel
impl Send for ConversationModel
impl !Sync for ConversationModel
impl Unpin for ConversationModel
impl UnwindSafe for ConversationModel
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self
