Comments (3)
Hi, the input length is automatically reduced to 512 tokens while leaving the tokens corresponding to labels intact. However, you need to define an appropriate PVP that always includes the maximum number of masks required for any label. Could you share your custom PVP?
Edit: As this was missing from the documentation, I've updated the README file accordingly: https://github.com/timoschick/pet#pet-with-multiple-masks
from pet.
Does this mean that i have to multiply self.mask by the number of maximum mask tokens?
Yes, exactly. I don't know how exactly "西大須"
gets tokenized, but if it consists of two tokens, you'll have to insert two masks (as you did in your bottom example).
from pet.
Thanks for the clarification. This is my PVP class. There is only 1 self.mask when returning get_parts.
class TestPVP(PVP):
VERBALIZER = {
"1": ["他"],
"2": ["西大須"]
}
def get_parts(self, example: InputExample) -> FilledPattern:
text_a = self.shortenable(example.text_a)
text_b = self.shortenable(example.text_b)
if self.pattern_id == 0:
return [self.mask, ':', text_a, text_b], []
elif self.pattern_id == 1:
return [self.mask, '問題は:', text_a, text_b], []
elif self.pattern_id == 2:
return [text_a, '(', self.mask, ')', text_b], []
elif self.pattern_id == 3:
return [text_a, text_b, '(', self.mask, ')'], []
elif self.pattern_id == 4:
return ['[ クラス分類:', self.mask, ']', text_a, text_b], []
elif self.pattern_id == 5:
return [self.mask, '-', text_a, text_b], []
else:
raise ValueError("No pattern implemented for id {}".format(self.pattern_id))
def verbalize(self, label) -> List[str]:
return TestPVP.VERBALIZER[label]
Thanks for the documentation.
respectively, your get_parts() method should always return a sequence that contains exactly 3 mask tokens
Does this mean that i have to multiply self.mask by the number of maximum mask tokens?
class TestPVP(PVP):
VERBALIZER = {
"1": ["他"],
"2": ["西大須"]
}
def get_parts(self, example: InputExample) -> FilledPattern:
text_a = self.shortenable(example.text_a)
text_b = self.shortenable(example.text_b)
if self.pattern_id == 0:
return [self.mask, self.mask, ':', text_a, text_b], []
elif self.pattern_id == 1:
return [self.mask, self.mask, '問題は:', text_a, text_b], []
elif self.pattern_id == 2:
return [text_a, '(', self.mask, self.mask, ')', text_b], []
elif self.pattern_id == 3:
return [text_a, text_b, '(', self.mask, self.mask, ')'], []
elif self.pattern_id == 4:
return ['[ クラス分類:', self.mask, self.mask, ']', text_a, text_b], []
elif self.pattern_id == 5:
return [self.mask, self.mask, '-', text_a, text_b], []
else:
raise ValueError("No pattern implemented for id {}".format(self.pattern_id))
def verbalize(self, label) -> List[str]:
return TestPVP.VERBALIZER[label]
from pet.
Related Issues (20)
- OSError: Model name 'clue/albert_chinese_tiny' was not found in tokenizers model name list HOT 2
- TypeError: expected str, bytes or os.PathLike object, not NoneType HOT 1
- ZeroDivisionError when reduction is set to 'wmean' while training iPET HOT 1
- Stuck at 'There are 0 Examples for Label [my_label]' During iPETs Example Selection for Next Generation
- There is no softmax
- Training Time Issue HOT 4
- GenPET commands with GPT-2 HOT 2
- RuntimeError on eval method HOT 2
- Token indices sequence length is longer than the specified maximum sequence length for this model HOT 2
- PET and iPET parameters
- Random seed parameter for iterations
- Data format for few-shot text classification
- Roberta-large using BPE tokenizer generates multi tokens. HOT 6
- API Usage
- How much test data do you use in your experiments?
- How to training PET model uses xlm-roberta with byte-level Byte-Pair-Encoding?
- How to reproduce results of the paper? HOT 1
- Clarification on how to interpret PET's results HOT 2
- A question about “Automatically Identifying Words That Can Serve as Labels for Few-Shot Text Classification”
- RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)` HOT 3
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 pet.