pub struct GptJLMHeadModel { /* private fields */ }
Expand description
§GPT-J Language Modeling head
GPT-J model with a decoding head (linear layer without bias). The weights of the linear layer are tied to the word embeddings It is made of the following blocks:
transformer
: Base GptJModel
Implementations§
Source§impl GptJLMHeadModel
impl GptJLMHeadModel
Sourcepub fn new<'p, P>(p: P, config: &GptJConfig) -> GptJLMHeadModel
pub fn new<'p, P>(p: P, config: &GptJConfig) -> GptJLMHeadModel
Build a new GptJLMHeadModel
§Arguments
p
- Variable store path for the root of the GPT-J modelconfig
-GptJConfig
object defining the model architecture
§Example
use rust_bert::gpt_j::{GptJConfig, GptJLMHeadModel};
use rust_bert::Config;
use std::path::Path;
use tch::{nn, Device};
let config_path = Path::new("path/to/config.json");
let device = Device::Cpu;
let p = nn::VarStore::new(device);
let config = GptJConfig::from_file(config_path);
let gpt_j: GptJLMHeadModel = GptJLMHeadModel::new(&p.root() / "gpt_j", &config);
pub fn forward_t( &self, input_ids: Option<&Tensor>, layer_past: Cache, attention_mask: Option<&Tensor>, token_type_ids: Option<&Tensor>, position_ids: Option<&Tensor>, input_embeds: Option<&Tensor>, _encoder_outputs: Option<&Tensor>, _decoder_input_ids: Option<&Tensor>, train: bool, ) -> Result<LMModelOutput, RustBertError>
Auto Trait Implementations§
impl Freeze for GptJLMHeadModel
impl RefUnwindSafe for GptJLMHeadModel
impl Send for GptJLMHeadModel
impl !Sync for GptJLMHeadModel
impl Unpin for GptJLMHeadModel
impl UnwindSafe for GptJLMHeadModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more