Comments (4)
Could you share the complete code where I could reproduce the error?
from lmppl.
Thank you for getting back to me. The code works fine. I figured out the problem and solved it. My inputs had many whitespaces and caused the problem of the tensors mismatch. I will close this issue.
from lmppl.
Can I ask how you fixed the whitespace issue? I am struggling with the same thing, but whenever I try to fix it, I get a different error.
from lmppl.
The code was fine with English texts, but once you use it with a multilingual text, Arabic in my case, you get this error. I did many things to reduce this error, like removing extra whitespace, newlines(\n), tabs (\t), and even digits. The code worked but was still buggy.
Therefore, I had to write my code from scratch and adopted a different approach to compute the perplexity for MLMs. I used the work of Salazar et al., "Masked Language Model Scoring", https://arxiv.org/abs/1910.14659. I noticed that their work has a limitation: the pseudo-perplexity score is susceptible to the length of the sentences, so I have to manage that by setting min and max for sentences, unless you do not care. In my case, it mattered because I was comparing many MLMs' performances, so a consistent comparison is crucial.
You can look at this StackOverflow thread "How to calculate perplexity of a sentence using huggingface masked language models?" or take a look at my rough implementation: https://github.com/SaiedAlshahrani/pImplications/blob/main/pseudo_ppl.py. You might need to change many things to get it to work for your needs.
from lmppl.
Related Issues (9)
- RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:7 and cuda:0! HOT 13
- ppl in openai model HOT 1
- Handling of long input HOT 3
- A quite large perplexity issue HOT 2
- Dataset too large HOT 30
- ImportError while trying to use device_map = "auto" parameter.
- Can the LLAMA model be used for this project, please HOT 1
- Please Update Readme - Available Models
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 lmppl.