Added solution
This commit is contained in:
parent
feb2bca7d4
commit
8e8dfc8df8
@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 4,
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from transformers import pipeline\n",
|
"from transformers import pipeline\n",
|
||||||
@ -22,8 +22,8 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false,
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"start_time": "2024-06-05T22:18:09.683477Z",
|
"start_time": "2024-06-09T12:13:28.590508Z",
|
||||||
"end_time": "2024-06-05T22:18:18.482741Z"
|
"end_time": "2024-06-09T12:13:40.429636Z"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -38,16 +38,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 5,
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"No model was supplied, defaulted to dbmdz/bert-large-cased-finetuned-conll03-english and revision f2482bf (https://huggingface.co/dbmdz/bert-large-cased-finetuned-conll03-english).\n",
|
|
||||||
"Using a pipeline without specifying a model name and revision in production is not recommended.\n",
|
|
||||||
"C:\\Users\\adamw\\PycharmProjects\\pythonProject\\venv\\lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
|
|
||||||
" warnings.warn(\n",
|
|
||||||
"Some weights of the model checkpoint at dbmdz/bert-large-cased-finetuned-conll03-english were not used when initializing BertForTokenClassification: ['bert.pooler.dense.bias', 'bert.pooler.dense.weight']\n",
|
"Some weights of the model checkpoint at dbmdz/bert-large-cased-finetuned-conll03-english were not used when initializing BertForTokenClassification: ['bert.pooler.dense.bias', 'bert.pooler.dense.weight']\n",
|
||||||
"- This IS expected if you are initializing BertForTokenClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
|
"- This IS expected if you are initializing BertForTokenClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
|
||||||
"- This IS NOT expected if you are initializing BertForTokenClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n"
|
"- This IS NOT expected if you are initializing BertForTokenClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n"
|
||||||
@ -60,8 +56,8 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false,
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"start_time": "2024-06-05T22:18:18.486678Z",
|
"start_time": "2024-06-09T12:13:40.436629Z",
|
||||||
"end_time": "2024-06-05T22:18:22.305194Z"
|
"end_time": "2024-06-09T12:13:43.520630Z"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -135,6 +131,42 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"source": [
|
||||||
|
"### Przykładowe użycie"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": "[{'entity': 'I-ORG',\n 'score': 0.9995635,\n 'index': 1,\n 'word': 'Hu',\n 'start': 0,\n 'end': 2},\n {'entity': 'I-ORG',\n 'score': 0.99159384,\n 'index': 2,\n 'word': '##gging',\n 'start': 2,\n 'end': 7},\n {'entity': 'I-ORG',\n 'score': 0.99826705,\n 'index': 3,\n 'word': 'Face',\n 'start': 8,\n 'end': 12},\n {'entity': 'I-ORG',\n 'score': 0.9994404,\n 'index': 4,\n 'word': 'Inc',\n 'start': 13,\n 'end': 16},\n {'entity': 'I-LOC',\n 'score': 0.99943465,\n 'index': 11,\n 'word': 'New',\n 'start': 40,\n 'end': 43},\n {'entity': 'I-LOC',\n 'score': 0.99932706,\n 'index': 12,\n 'word': 'York',\n 'start': 44,\n 'end': 48},\n {'entity': 'I-LOC',\n 'score': 0.9993864,\n 'index': 13,\n 'word': 'City',\n 'start': 49,\n 'end': 53},\n {'entity': 'I-LOC',\n 'score': 0.9825622,\n 'index': 19,\n 'word': 'D',\n 'start': 79,\n 'end': 80},\n {'entity': 'I-LOC',\n 'score': 0.936983,\n 'index': 20,\n 'word': '##UM',\n 'start': 80,\n 'end': 82},\n {'entity': 'I-LOC',\n 'score': 0.89870995,\n 'index': 21,\n 'word': '##BO',\n 'start': 82,\n 'end': 84},\n {'entity': 'I-LOC',\n 'score': 0.97582406,\n 'index': 29,\n 'word': 'Manhattan',\n 'start': 113,\n 'end': 122},\n {'entity': 'I-LOC',\n 'score': 0.99024945,\n 'index': 30,\n 'word': 'Bridge',\n 'start': 123,\n 'end': 129}]"
|
||||||
|
},
|
||||||
|
"execution_count": 9,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"sequence = \"Hugging Face Inc. is a company based in New York City. Its headquarters are in DUMBO, therefore very\" \\\n",
|
||||||
|
" \"close to the Manhattan Bridge which is visible from the window.\"\n",
|
||||||
|
"model_out = nlp(sequence)\n",
|
||||||
|
"model_out"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false,
|
||||||
|
"ExecuteTime": {
|
||||||
|
"start_time": "2024-06-09T12:14:36.626686Z",
|
||||||
|
"end_time": "2024-06-09T12:14:36.815685Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"source": [
|
"source": [
|
||||||
|
Loading…
Reference in New Issue
Block a user