Comments (4)
@kj3moraes just had a look and I believe I have found the issue. The default maximum length for the text generation pipeline is 56 tokens (this includes the input prompt). Your input prompt most likely exceeds the 56 token default of the pipeline, and you have 2 solutions:
- Change the
max_length
value of theTextGenerationConfig
(you are currently using the default constructor). This is probably what you want to to. - pass a prompt that is shorter than the maximum length for text generation
Please let me know how this works. I will add a check to improve error handling when users provide inputs longer than the maximum length, thank you for raising this.
from rust-bert.
Hello @kj3moraes ,
Thank you for raising this. Could you please share a reproducible example (i.e. with a prompt and file you could share publicly) and turning the sampling off for the generation?
from rust-bert.
Thank you for raising this. Could you please share a reproducible example (i.e. with a prompt and file you could share publicly) and turning the sampling off for the generation?
This is the prompt that I use
Task: Extract summary and keywords from code
You are given a file containing code in a programming language. Your task is to reads the code from the file and generates a JSON output with two keys - 'summary' and 'keywords'.
1. 'summary': A string describing what the code is doing. This summary should capture the main purpose or functionality of the code in a concise manner.
2. 'keywords': A list of strings that includes relevant keywords related to the programming language used, the task being performed, or any significant terms present in the code.
The following is an example:
INPUT:
from transformers import pipeline
image_to_text_model = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
def convert_image_to_text(image_path: str) -> str :
return image_to_text_model(image_path)
{
"summary": "Function to caption the image at the specified path and returns it as a string",
"keywords": ["python", "huggingface", "transformers", "image", "caption", "captioning"]
}
INPUT:
An example file would be
use std::path::PathBuf;
pub fn path_to_string(path: &PathBuf) -> String {
path.display().to_string()
}
pub fn path_to_filename_string(path: &PathBuf) -> Option<String> {
Some(path.file_name()?.to_str()?.to_string())
}
from rust-bert.
* Change the `max_length` value of the [`TextGenerationConfig`](https://github.com/guillaume-be/rust-bert/blob/9f2cd17e914dee9570e981c63a4021beb33250c2/src/pipelines/text_generation.rs#L59) (you are currently using the default constructor). This is probably what you want to to.
This worked thanks a lot. Returning a Result would be better for sure.
from rust-bert.
Related Issues (20)
- Is multilabel prediction correct? HOT 1
- Evaluation fails when trying to extract keywords from a specific sentence HOT 2
- Please expose tonekizer params on models where `forward_t` is exposed
- Downloading a model to a local Directory HOT 4
- Question: Configuring ZeroShotClassificationModel with DeBERTaV2 - Documentation HOT 1
- Upgrade Cargo dependencies HOT 2
- Any plan to release a new version? HOT 2
- Question: is it ok to continue after OOM error from `encode`
- update to be working with torch 2.2.0
- support for huggingface access token
- Error on running example in Linux
- RemoteResource doesn't allow loading safetensors models
- linking with `cc` failed: exit status: 1
- Double free or corruption (fasttop) HOT 1
- The example for linking the lib is incorrect.
- Feature Request: inference with rust bert models in asynchronous web applications HOT 1
- Converted msmarco-distilbert-cos-v5 model with convert_model.py fails when loaded with Tch tensor error: cannot find the tensor named distilbert.transformer.layer.0.attention.v_lin.bias HOT 2
- Loading multi-file pytorch_model.bin files (eg. Mistral)? HOT 2
- NER with BERT-based Model: Unexpected Panic During Prediction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bert.