Struct rust_bert::pipelines::conversation::ConversationModel [−][src]
Conversation model
Processes a ConversationManager and generate system responses for active conversations.
Implementations
impl ConversationModel
[src]
pub fn new(
conversation_config: ConversationConfig
) -> Result<ConversationModel, RustBertError>
[src]
conversation_config: ConversationConfig
) -> Result<ConversationModel, RustBertError>
Build a new ConversationModel
Arguments
conversation_config
-ConversationConfig
object 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>
[src]
&self,
conversation_manager: &'a mut ConversationManager
) -> HashMap<&'a Uuid, &'a str>
Perform a multi-turn conversation based on user input
Arguments
conversation_manager
-&mut ConversationManager
Conversation 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);
pub fn encode_prompts(&self, texts: &[&str]) -> Vec<Vec<i64>>
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,