Using the T5 model with huggingface's mask-fill pipeline - neural-network

Does anyone know if it is possible to use the T5 model with hugging face's mask-fill pipeline? The below is how you can do it using the default model but i can't seem to figure out how to do is using the T5 model specifically?
from transformers import pipeline
nlp_fill = pipeline('fill-mask')
nlp_fill('Hugging Face is a French company based in ' + nlp_fill.tokenizer.mask_token)
Trying this for example raises the error "TypeError: must be str, not NoneType" because nlp_fill.tokenizer.mask_token is None.
nlp_fill = pipeline('fill-mask',model="t5-base", tokenizer="t5-base")
nlp_fill('Hugging Face is a French company based in ' + nlp_fill.tokenizer.mask_token)

Related

Unable to Change Format When Using Parameters to Swap Fields in Tableau

I am Unable to Change Format(Incremental RR is in percentage(%) and rest are in numbers($)) When Using Parameters to Swap Fields. I have created one parameter named -Select metric and written calculation as below:
IF [Select Metric]='Avg HH-Balance' then [Average Balance]
ELSEIF [Select Metric]='CPI-HH (Checking)' then [CPI-HH (Checking)]
ELSEIF [Select Metric]='CPI-A (Any Acct)' then [CPI-A (Any Acct)]
ELSEIF [Select Metric]='Incremental RR' then [Incremental Response Rate] else null
END
The format it's taking is Automatic but I want the axis to change according to the selection of parameters.Thanks.
Check out this great answer from Andy Kriebel.

Tagging and Training NER dataset

I have a data set and I want to tag it for Named Entity Recognition. My dataset is in Persian.
I want to know how should I tag expressions like :
*** آقای مهدی کاظمی = Mr Mehdi Kazemi / Mr will Smith. >>> (names with titles) should I tag all as a person or just the first name and last name should be tagged? (I mean should i also tag "Mr")
Mr >> b_per || Mr >> O
Mehdi >> i_per || Mehdi >> b_per
Kazemi >> i_per || Kazemi >> i_per
*** بیمارستان نور = Noor hospital >>> Should I tag the name only or the name and hospital both as Named Entity?
*** Eiffel tower / The Ministry of Defense (I mean the us DOD for example) >>> in Persian it is called :
وزارت دفاع (vezarate defa)
should I only tag Defense ? or all together?
There are many more examples for schools, movies, cities, countries and.... since we use the entity class before the named entity.
I would appreciate if you can help me with tagging this dataset.
I'll give you some examples from the CoNLL 2003 training data:
"Mr." is not tagged as part of the person, so titles are ignored.
"Columbia Presbyterian Hospital" is tagged as (LOC, LOC, LOC)
"a New York hospital" (O, LOC, LOC, O)
"Ministry of Commerce" is (ORG, ORG, ORG)
I think "Eiffel Tower" should be (LOC, LOC)
In general, you tag as the way you want the output to look. It's up to you if you want titles included, for example. However, Core NLP won't tag overlapping entities, so you have to make a decision in for cases like the hospital named after someone.
I believe you are heading to Stanford NLP and BIO format. But in case you'd also consider other options, you may have a look a structured entities such as: http://www.afcp-parole.org/etape/docs/etape-06022012-quaero-en.pdf.
Those allow to describe entities as trees, providing a finer analysis for information extraction. More tedious to annotate but probably relevant if you intend to use annotation for semantic purposes, not only indexing.

Changing tick type in IB API with Matlab

I am trying to request real time data using TWS via Matlab's IB API. I don't want regular market data though, specifically I am trying to obtain implied volatility. This is the guide I am using: http://www.mathworks.com/help/trading/ibtws.realtime.html
I should be able to obtain IV just by plaching f='106' according to IB API: https://www.interactivebrokers.com/en/software/api/api.htm
But everytime I get the same thing (RTVolume), that is, bid, ask, last etc. I am always getting market data regardless of what the integer ID flag is changed to.
This is my code:
try
close(ib);
close(conn);
catch
end
clear all;
ibBuiltInRealtimeData = struct('id',0,'BID_PRICE',0,'BID_SIZE',0,'ASK_PRICE',0,'ASK_SIZE',0);
while true
ib = ibtws('',7496);
f = '106';
ibContract = ib.Handle.createContract;
ibContract.symbol = 'AAPL';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
ibContract.primaryExchange = '';
ibContract.currency = 'USD';
tickerid = realtime(ib,ibContract,f);
d2 = ibBuiltInRealtimeData;
d2
pause(1);
end
And this is the output:
id: 5689.00
BID_PRICE: 102.55
BID_SIZE: 1.00
ASK_PRICE: 103.00
ASK_SIZE: 1.00
LAST_PRICE: 102.79
LAST_SIZE: 0
VOLUME: 434689.00
I see no implied volatility anywhere! How can I request real time data of other things besides market data?
It's an easy explanation but not the one you want to hear:
The contract you're using is a stock and not an option. Like you can read in the API Manual:
Note: not all tick types are available for all instruments at all times. If you are not receiving a specific tick type when you think you should see if the tick type in question is available within the TWS itself. Remember the TWS API is only a delivery channel: if the information is not available in the TWS itself first, the TWS will not be able to dispatch it via the API socket.
The tick type "Option Implied Volatility" (Tick Id 24) is used for options and therefore it's not available for stocks.
Just use another contract and you'll get your expected result.
I hope this helps.

Get rows with same field in ArcGIS 10.1

ArcGIS 10.1 using ArcObjects in .NET. Im well adept at iterating through all the features in a featureclass. However I've spent the better half of a day trying to look for a way to group features by a field.
I currently use:
Dim pFeatCursor As IFeatureCursor = pPolylineFeatLayer.Search(Nothing, False)
Dim pPolylineFeature As IFeature = pFeatCursor.NextFeature
While Not pPolylineFeature Is Nothing
'do something with the single feature
pPolylineFeature = pFeatCursor.NextFeature
End While
What Im trying to do is:
'group features by fields "CODE3" and "AIDX"
for every group
'dump that group of features to it's own featureclass
next group
I've been looking at several cursor classes and cant seem to find any that do this type of query. this python function seems to do the trick but need to do this in .NET and this tool is only available in ModelBuilder.
arcpy.IterateFeatureSelection_mb( Input_Features, Group_By_Fields, "false")
You could try to use IQueryFilterDefinition.PostfixClause with a 'GROUP BY' or 'ORDER BY'

MATLAB/SIMULINK dynamic bus conversion with embedded Matlab function

I'm working on automated model building. In some cases I have do convert a bus into another bus (the structure is the same, but there can be variants in the names). It works for a static model where I can change the datatype of the inputs and outputs, but I didn't find any way to do this from the command line or directly in an embedded MATLAB function.
Does anybody know a way to do this?
mfb = find(sfroot, '-isa', 'Stateflow.EMChart', 'Name', 'test');
out = get(mfb, 'Outputs');
out.set('DataType', ['Bus: ' component_source.test]);