Not able to test it.

#21
by JESUSCOLIN - opened

Hi, I spend some time testing the onnx model. Can someone identify the issue, the are not clear instructions and I am new on this.

from onnxruntime import InferenceSession
import numpy as np
from transformers import AutoTokenizer

session = InferenceSession("model.onnx")
long_text =" A typical feed-forward neural field algorithm. Spatiotemporal coordinates are fed into a neural network that predicts values in the reconstructed domain. Then, this domain is mapped to the sensor domain where sensor measurements are available as supervision. Class and Section Problems Addressed Generalization (Section 2) Inverse problems, ill-posed problems, editability; symmetries. Hybrid Representations (Section 3) Computation & memory efficiency, representation capacity, editability: Forward Maps (Section 4) Inverse problems Network Architecture (Section 5) Spectral bias, integration & derivatives. Manipulating Neural Fields (Section 6) Edit ability, constraints, regularization. Table 2: The five classes of techniques in the neural field toolbox each addresses problems that arise in learning, inference, and control. (Section 3). We can supervise reconstruction via differentiable forward maps that transform Or project our domain (e.g, 3D reconstruction via 2D images; Section 4) With appropriate network architecture choices, we can overcome neural network spectral biases (blurriness) and efficiently compute derivatives and integrals (Section 5). Finally, we can manipulate neural fields to add constraints and regularizations, and to achieve editable representations (Section 6). Collectively, these classes constitute a 'toolbox' of techniques to help solve problems with neural fields There are three components in a conditional neural field: (1) An encoder or inference function € that outputs the conditioning latent variable 2 given an observation 0 E(0) =2. 2 is typically a low-dimensional vector, and is often referred to aS a latent code Or feature code_ (2) A mapping function 4 between Z and neural field parameters O: Y(z) = O; (3) The neural field itself $. The encoder € finds the most probable z given the observations O: argmaxz P(2/0). The decoder maximizes the inverse conditional probability to find the most probable 0 given Z: arg- max P(Olz). We discuss different encoding schemes with different optimality guarantees (Section 2.1.1), both global and local conditioning (Section 2.1.2), and different mapping functions Y (Section 2.1.3) 2. Generalization Suppose we wish to estimate a plausible 3D surface shape given a partial or noisy point cloud. We need a suitable prior over the sur- face in its reconstruction domain to generalize to the partial observations. A neural network expresses a prior via the function space of its architecture and parameters 0, and generalization is influenced by the inductive bias of this function space (Section 5)."
tokenizer = AutoTokenizer.from_pretrained("t5-base")

input_dict = tokenizer(long_text, return_tensors="np", padding="max_length", truncation=True, max_length=3)
input_ids = input_dict["input_ids"]
attention_mask = input_dict["attention_mask"]
decoder_input_ids = np.zeros_like(input_ids) # Puede variar según tus necesidades

input_feed = {
"input_ids": input_ids.astype(np.int64),
"attention_mask": attention_mask.astype(np.int64),
"decoder_input_ids": decoder_input_ids.astype(np.int64)
}

output_names = ["logits"] # Not sure about this output_names

outputs = session.run(output_names, input_feed)

summary_ids = outputs[0]
summary_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True)

print(summary_text)

JESUSCOLIN changed discussion status to closed

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained('./')
model = AutoModelForSeq2SeqLM.from_pretrained('./')
def generate_text(input_text):
input_ids = tokenizer.encode(input_text, return_tensors='pt')
output_ids = model.generate(input_ids)
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
return output_text
long_text =" ...."
print(generate_text(long_text))

FYI

hi! thanks for reaching out. I just finetuned the model and posted it, if you're looking for support on how how use a model with optimum, I would recommend checking out the forums. If something is not working with optimum, you can create an issue in the repo

if something works with most other T5/long-T5 models and does not with this one, then that is something that should be here :)

Sign up or log in to comment