Related
Model type should be one of BartConfig, PLBartConfig, BigBirdPegasusConfig, M2M100Config, LEDConfig, BlenderbotSmallConfig, MT5Config, T5Config, PegasusConfig, MarianConfig, MBartConfig, BartConfig, BlenderbotConfig, FSMTConfig, XLMProphetNetConfig, ProphetNetConfig, EncoderDecoderConfig.
I am trying to load a fine-tuned Bert model for machine translation using AutoModelForSeq2SeqLM but it can't recognize the configuration class.
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, Seq2SeqTrainingArguments, Seq2SeqTrainer
model = AutoModelForSeq2SeqLM.from_pretrained('/content/drive/MyDrive/Models/CSE498')
Config File
{
"_name_or_path": "ckiplab/albert-tiny-chinese",
"architectures": [
"BertForMaskedLM"
],
"attention_probs_dropout_prob": 0.0,
"bos_token_id": 101,
"classifier_dropout": null,
"classifier_dropout_prob": 0.1,
"down_scale_factor": 1,
"embedding_size": 128,
"eos_token_id": 102,
"gap_size": 0,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.0,
"hidden_size": 312,
"initializer_range": 0.02,
"inner_group_num": 1,
"intermediate_size": 1248,
"layer_norm_eps": 1e-12,
"max_position_embeddings": 512,
"model_type": "bert",
"net_structure_type": 0,
"num_attention_heads": 12,
"num_hidden_groups": 1,
"num_hidden_layers": 4,
"num_memory_blocks": 0,
"pad_token_id": 0,
"position_embedding_type": "absolute",
"tokenizer_class": "BertTokenizerFast",
"torch_dtype": "float32",
"transformers_version": "4.18.0",
"type_vocab_size": 2,
"use_cache": true,
"vocab_size": 30522
}
This is because BERT itself is not a seq2seq model. You can consider using a pre-trained BART instead.
I'm developing a solution that integrates with LUIS using API calls.
I can't find the API to get information from the Dashboard as for example incorrect predictions and unclear predictions. So far I found just this API:
{ENDPOINT}/luis/webapi/v2.0/apps/{APP_ID}/versions/{VERSION}/statsmetadata
but this is not enough, since I would get more detailed information like the one displayed in the dashboard:
The statsmetadata endpoint is the right operation for displaying the figures for the pie chart.
Sample
Here is an example in one of my LUIS apps
Dashboard display
The dashboard gives the following details:
Data origin
StatsMetadata endpoint gives all the details. Here is the call that is made: https://westeurope.api.cognitive.microsoft.com//luis/webApi/v2.0/apps/*MyAppId*/versions/*MyAppVersion*/statsmetadata
JSON Result:
{
"appVersionUtterancesCount": 8505,
"modelsMetadata": [{
"modelId": "IdOfModel1,
"modelName": "modelName1",
"utterancesCount": 85,
"misclassifiedUtterancesCount": 7,
"ambiguousUtterancesCount": 19,
"misclassifiedAmbiguousUtterancesCount": 7
}, {
"modelId": "IdOfModel2",
"modelName": "modelName2",
"utterancesCount": 402,
"misclassifiedUtterancesCount": 11,
"ambiguousUtterancesCount": 32,
"misclassifiedAmbiguousUtterancesCount": 11
}, {
"modelId": "IdOfModel3",
"modelName": "modelName3",
"utterancesCount": 293,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 42,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel4",
"modelName": "modelName4",
"utterancesCount": 58,
"misclassifiedUtterancesCount": 3,
"ambiguousUtterancesCount": 5,
"misclassifiedAmbiguousUtterancesCount": 3
}, {
"modelId": "IdOfModel5",
"modelName": "modelName5",
"utterancesCount": 943,
"misclassifiedUtterancesCount": 7,
"ambiguousUtterancesCount": 103,
"misclassifiedAmbiguousUtterancesCount": 7
}, {
"modelId": "IdOfModel6",
"modelName": "modelName6",
"utterancesCount": 266,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 70,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel7",
"modelName": "modelName7",
"utterancesCount": 2441,
"misclassifiedUtterancesCount": 68,
"ambiguousUtterancesCount": 180,
"misclassifiedAmbiguousUtterancesCount": 67
}, {
"modelId": "IdOfModel8",
"modelName": "modelName8",
"utterancesCount": 704,
"misclassifiedUtterancesCount": 40,
"ambiguousUtterancesCount": 154,
"misclassifiedAmbiguousUtterancesCount": 40
}, {
"modelId": "IdOfModel9",
"modelName": "modelName9",
"utterancesCount": 288,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 65,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel10",
"modelName": "modelName10",
"utterancesCount": 18,
"misclassifiedUtterancesCount": 1,
"ambiguousUtterancesCount": 1,
"misclassifiedAmbiguousUtterancesCount": 1
}, {
"modelId": "IdOfModel11",
"modelName": "modelName11",
"utterancesCount": 444,
"misclassifiedUtterancesCount": 12,
"ambiguousUtterancesCount": 50,
"misclassifiedAmbiguousUtterancesCount": 12
}, {
"modelId": "IdOfModel12",
"modelName": "modelName12",
"utterancesCount": 10,
"misclassifiedUtterancesCount": 8,
"ambiguousUtterancesCount": 8,
"misclassifiedAmbiguousUtterancesCount": 8
}, {
"modelId": "IdOfModel13",
"modelName": "modelName13",
"utterancesCount": 58,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 21,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel14",
"modelName": "None",
"utterancesCount": 2495,
"misclassifiedUtterancesCount": 194,
"ambiguousUtterancesCount": 428,
"misclassifiedAmbiguousUtterancesCount": 178
}],
"intentsCount": 14,
"entitiesCount": 7,
"phraseListsCount": 7,
"patternsCount": 0,
"trainingTime": "00:00:53.2732860",
"lastTrainDate": "2019-10-22T13:25:03Z",
"misclassifiedUtterancesCount": 387,
"ambiguousUtterancesCount": 1178,
"misclassifiedAmbiguousUtterancesCount": 370
}
Calculation on API data - Pie Chart
Incorrect predictions
Here it is the number of misclassified utterances divided by the total number of utterances
Formula: misclassifiedUtterancesCount / appVersionUtterancesCount
Check: 387 / 8505 = 0.04550 = 4.6%
Unclear predictions
Here it is the number of ambiguous (but not misclassified ambiguous as they are already counted in incorrect predictions) utterances divided by the total number of utterances
Formula: (ambiguousUtterancesCount - misclassifiedAmbiguousUtterancesCount) / appVersionUtterancesCount
Check: (1178 - 370) / 8505 = 808 / 8505 = 0.09500 = 9.5%
Correct predictions
It is... what remains! So:
Formula: (appVersionUtterancesCount - misclassifiedUtterancesCount - (ambiguousUtterancesCount - misclassifiedAmbiguousUtterancesCount)) / appVersionUtterancesCount
Check: (8505 - 387 - (1178 - 370)) / 8505 = (8505 - 387 - 808) / 8505 = 7310 / 8505 = 0.8594 = 85.9%
Calculation on API data - Right panel details
Data Imbalance
It is the models that have the biggest number of utterancesCount, but I don't know if there is a threshold ratio used to keep only the top N models
Incorrect predictions
By model, check the following ratio: misclassifiedUtterancesCount / utterancesCount and keep the ones having the highest ratio.
Unclear predictions
By model, check the following ratio: (ambiguousUtterancesCount - misclassifiedAmbiguousUtterancesCount) / utterancesCount and keep the ones having the highest ratio.
Details
You can directly check in your navigator developer tools that LUIS portal is calling this endpoint before displaying the dashboard.
function createData(collegeName, registrarName, phoneNumber, emailAddress, action) {
return {collegeName , registrarName, phoneNumber, emailAddress, action };
}
var rows = [
createData("data", 305, 3.7, 67, 4.3),
createData('Donut', 452, 25.0, 51, 4.9),
createData('Eclair', 262, 16.0, 24, 6.0),
createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
createData('Gingerbread', 356, 16.0, 49, 3.9),
createData('Honeycomb', 408, 3.2, 87, 6.5),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
createData('Jelly Bean', 375, 0.0, 94, 0.0),
createData('KitKat', 518, 26.0, 65, 7.0),
createData('Lollipop', 392, 0.2, 98, 0.0),
createData('Marshmallow', 318, 0, 81, 2.0),
createData('Nougat', 360, 19.0, 9, 37.0),
createData('Oreo', 437, 18.0, 63, 4.0),
];
this is static data (you can check using full code for table ) but i want to feed rows by dynamic data :this is the response of database
You shoul use a Map to generate an input for your table rows property:
let list = (data && data.profiles != null) ? data.profiles.map((value, index, array) => {
return {
id: value.id,
key: value.id,
name: value.name,
})
Above code is an example, change variables to your owns.
With the following javascript request:
navigator.credentials.create({
publicKey: {
// random, cryptographically secure, at least 16 bytes
challenge: new Uint8Array(16),
// relying party
rp: {
id: 'localhost',
name: 'My website'
},
user: {
id: new Uint8Array(16),
name: 'Tang',
displayName: 'Tang'
},
pubKeyCredParams: [
{
type: "public-key", alg: -7
}
],
attestation: "direct"
}
})
a FIDO2-compatible Yubikey 5 NFC systematically returns a "fido-u2f" attestation statement:
%{
"attStmt" => %{
"sig" => <<48, 69, 2, 33, 0, 132, 31, 225, 91, 58, 61, 190, 47, 66, 168, 8,
177, 18, 136, 106, 100, 219, 54, 52, 255, 103, 106, 156, 230, 141, 240,
82, 130, 167, 204, 128, 100, 2, 32, 61, 159, 126, 9, 244, 55, 100, 123,
169, ...>>,
"x5c" => [
<<48, 130, 2, 188, 48, 130, 1, 164, 160, 3, 2, 1, 2, 2, 4, 3, 173, 240,
18, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 46, 49,
44, 48, 42, 6, 3, 85, 4, 3, 19, ...>>
]
},
"authData" => <<73, 150, 13, 229, 136, 14, 140, 104, 116, 52, 23, 15, 100,
118, 96, 91, 143, 228, 174, 185, 162, 134, 50, 199, 153, 92, 243, 186, 131,
29, 151, 99, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>,
"fmt" => "fido-u2f"
}
How to receive a FIDO2 "packed" attestation statement instead?
Per the current spec/standard I don't think you (acting as a Relying Party) can "select" which attestation statement format you receive from the Authenticator (i.e. "the device"). That is a decision made by the Authenticator.
I think MacBook Pro TouchID platform authenticator via Chrome Desktop is sending "packed" attestation statements, if that helps.
There is no way to select the attestation using such simple keys. To test my implementation for both attestations I simply bought two different keys one from Yibico and one from Nitrokey. Yubico sends fido-u2f, while the Nitrokey sends packed attestations.
And if someone likes to know, this is how I implemented that:
let verifyAuthenticatorAttestationResponse = (webAuthnResponse) => {
let attestationBuffer =
base64url.toBuffer(webAuthnResponse.response.attestationObject);
let ctapMakeCredResp = cbor.decodeAllSync(attestationBuffer)[0];
let authrDataStruct = parseMakeCredAuthData(ctapMakeCredResp.authData);
let response = {'verified': false };
if(ctapMakeCredResp.fmt === 'fido-u2f' || ctapMakeCredResp.fmt === 'packed') {
if(!(authrDataStruct.flags & U2F_USER_PRESENTED))
throw new Error('User was NOT presented durring authentication!');
let clientDataHash =
hash(base64url.toBuffer(webAuthnResponse.response.clientDataJSON))
let publicKey = COSEECDHAtoPKCS(authrDataStruct.COSEPublicKey)
let PEMCertificate = ASN1toPEM(ctapMakeCredResp.attStmt.x5c[0]);
let signature = ctapMakeCredResp.attStmt.sig;
let signatureBase;
if(ctapMakeCredResp.fmt === 'fido-u2f') {
signatureBase = Buffer.concat([Buffer.from([0x00]), authrDataStruct.rpIdHash, clientDataHash, authrDataStruct.credID, publicKey]);
} else {
signatureBase = Buffer.concat([ctapMakeCredResp.authData, clientDataHash]);
}
response.verified = verifySignature(signature, signatureBase, PEMCertificate)
if(response.verified) {
response.authrInfo = {
fmt: `${ctapMakeCredResp.fmt}`,
publicKey: base64url.encode(publicKey),
counter: authrDataStruct.counter,
credID: base64url.encode(authrDataStruct.credID)
}
}
}
return response
}
By default the browser might select U2F. Try forcing UV by setting it to "required". This will force browser to use FIDO2 as U2F does not support UV.
I am trying to pass an array of arrays from routes to view page. My data that I am trying to pass is :
[
[10, 10],
[20, 50],
[30, 120],
[40, 80],
[50, 90],
[60, 50],
[70, 70],
[80, 90],
[90, 150],
[100, 50],
[110, 40],
[120, 70],
[130, 20],
[140, 40],
[200, 30]
]
I am getting it in below format:
["10,10,20,50,30,120,40,80,50,90,60,50,70,70,80,90,90,150,100,50,110,40,120,70,130,20,140,40,200,30"]
but I need it in the same format I am sending.
My index.js(routes file) is:
router.get('/', function(req, res, next) {
var dataset = [
[10, 10],
[20, 50],
[30, 120],
[40, 80],
[50, 90],
[60, 50],
[70, 70],
[80, 90],
[90, 150],
[100, 50],
[110, 40],
[120, 70],
[130, 20],
[140, 40],
[200, 30]
];
console.log(dataset);
res.render('index',{"data" : [dataset]});
});
module.exports = router;
and in my view file, I am trying to get it like:
<div class="hold_data" data-info={{data}}></div>
Please suggest if anyone knows how this can be achieved. Thanks in advance :)
Try JSON.stringify as below -
res.render('index',{"data" : JSON.stringify(dataset)});
Hope this helps.