Coder Social home page Coder Social logo

microsoftlearning / mslearn-ai-language Goto Github PK

View Code? Open in Web Editor NEW
87.0 7.0 183.0 1.39 MB

Lab files for Azure AI Language modules

Home Page: https://microsoftlearning.github.io/mslearn-ai-language/

License: MIT License

C# 52.90% Python 29.80% Shell 1.90% PowerShell 15.40%

mslearn-ai-language's Introduction

mslearn-ai-language

Lab files for Azure AI Language modules

mslearn-ai-language's People

Contributors

dxvsh avatar graememalcolm avatar infhyroyage avatar ivorb avatar jkulbe-msft avatar markpatterson27 avatar massimobonanni avatar mattobs avatar mihai-ac avatar mkennten avatar mpdacey avatar nick-konovalchuk avatar padamson avatar paul-iveylabs avatar sdstony avatar zpratikpathak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mslearn-ai-language's Issues

Lab 5 - Analyze Text - Incorrect folder name

In several parts of the instructions, the folder referenced is text-analytics, when the folder is actually called text-analysis. Other parts of the instructions refer to the correct name.

Rename this local variable "detectedLanguage" to match the regular expression ^[_a-z][a-z0-9_]*$.

Hello, How do I solve these issues:

1)Problem in .py file: Rename this local variable "detectedLanguage" to match the regular expression ^[a-z][a-z0-9]*$.

2)I have checked the key/endpoint. When I attempt to dectect language by reruning the .py file in the Terminal, this error appears:

(401) Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.Code: 401 Message: Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.

Dependencies missing and VSC does not auto update

Recently started using the repo and notice each time i clone it to my local machine, i start seeing a lot of errors for the Microsoft C# extension.

Here are just some. Literally every project for C# won't load.

c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Newtonsoft.Json with version (>= 12.0.3)

  • Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 9.0.1 ]
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.WindowsDesktop.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.AspNetCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.Extensions.Configuration.Json. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.WindowsDesktop.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.AspNetCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.Extensions.Configuration.Json. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.WindowsDesktop.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.AspNetCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.CognitiveServices.Speech. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.Extensions.Configuration.Json. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package System.Windows.Extensions. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.WindowsDesktop.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.AspNetCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:35 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\07-speech\C-Sharp\speaking-clock\speaking-clock.csproj: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Info - 11:27:45 AM] [LanguageServerProjectSystem] Completed (re)load of all projects in 00:00:11.8654251
    [Warn - 11:27:46 AM] [LanguageServerProjectSystem] Project c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj has unresolved dependencies
    Microsoft.Extensions.Configuration.Json-3.1.3
    Newtonsoft.Json-12.0.3
    [Error - 11:27:46 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj: Unable to find package Microsoft.Extensions.Configuration.Json. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:46 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj: Unable to find package Newtonsoft.Json with version (>= 12.0.3)
  • Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 9.0.1 ]
    [Error - 11:27:46 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:46 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj: Unable to find package Microsoft.WindowsDesktop.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:46 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj: Unable to find package Microsoft.AspNetCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Error - 11:27:46 AM] [LanguageServerProjectSystem] Failure while loading c:\Users\ssgil\melearnai\mslearn-ai-language\Labfiles\06-translate-text\C-Sharp\text-translation\translate_text.csproj: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
    [Info - 11:27:47 AM] [LanguageServerProjectSystem] Completed (re)load of all projects in 00:00:01.8937441

Lab 6 - Create a Question Answering Solution - Missing instructions

Hey team,

Seems like the product team now mandates using an Azure Search instance when using custom question answering projects (might be true for other types too). We should add the instructions to create the search instance at the beginning of the project creation.

image

01-analyze-text Python exercise requires missing python-dotenv package

Description

The Python version of the 01-analyze-text exercise requires the dotenv package which is missing from the base Python environment on Azure.

Screenshots

image

To Reproduce

Error occurs at Step 6 in section "Prepare to use the Azure AI Language SDK for text analytics" of 01-analyze-text.md.

Files

https://github.com/MicrosoftLearning/mslearn-ai-language/blob/main/Instructions/Exercises/01-analyze-text.md

Tasks

Add pip install python-dotenv to above file.

[FEEDBACK] : Wrong text in exercise instruction (Exercises /02-qna.md)

Issue Summary

Description:
The text in step 4 in "Edit the knowledge base" section looks incorrect. While doing the exercise was not able to find the "What is Microsoft certification?" question.

Expected Behavior:
The text should be "What are Microsoft credentials?"

Actual Behavior:
Right now, the text is "What is Microsoft certification?" which is quite confusing.

Steps to Reproduce

  1. From exercise instruction perform all steps till the section "Add sources to the knowledge base".
  2. While performing step 4 from the section "Edit the knowledge base" verify the environment with instructions https://microsoftlearning.github.io/mslearn-ai-language/Instructions/Exercises/02-qna.html

Screenshots

image

Lab 03 - datetime.datetime.utcnow() is deprecated sinze Python 3.12

At my python 3.12 environment, it has occurred this warning lab 03 python:

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

There are datetime.datetime.utcnow() which is deprecated since python 3.12. See https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow .

Issue with lab File /05-custom-entity-recognition/extract-entities.ps1

For the lab: 05-custom-entity-recognition/extract-entities.ps1, it seems the request URI and the request is not aligned with the schema. Suggested code is provided as follows:

# Update these with your service and deployment values
$key="<YOUR-KEY>"
$endpoint="<YOUR-ENDPOINT>"
$projectName = "customNERLab"
$deploymentName = "customExtractAds"
$verbose = $false

# Set up headers for API call
$headers = @{}
$headers.add("Ocp-Apim-Subscription-Key", $key)
$headers.add("Content-Type","application/json")

# Get text to extract entities from
$text_file = "test1.txt"
if ($args.count -gt 0)
{
    $text_file = $args[0]
}

try {
    $contents = get-content $text_file -raw -ErrorAction Stop
}
catch {
    Write-Host "`nError reading provided file, please verify file exists`n"
    Exit
}

$data = @{
    "displayName" = "Extracting entities"
    "tasks" = @(
        @{
            "kind" = "CustomEntityRecognition"
            "taskName" = "Entity Recognition"
            "parameters"= @{
                        "projectName" = $projectName
                        "deploymentName" = $deploymentName
                    }
        }
    )
    "analysisInput" = @{
        "documents" = @(
            @{
                "id" = "document_extractEntities"
                "language" = "en-us"
                "text" = $contents
            }
        )
    }
} | ConvertTo-Json -Depth 10



# Post text for entity recognition
Write-Host("`nSubmitting entity recognition task`n")
$response = Invoke-WebRequest -Method Post `
          -Uri "$($endpoint)language/analyze-text/jobs?api-version=2022-10-01-preview" `
          -Headers $headers `
          -Body $data

# Output response if desired
if ($verbose) {
    Write-Host("`nResponse header:$($response.Headers['Operation-Location'])`n")
}

# Extract the URL from the response
# to call the API to getting the analysis results
$resultUrl = $($response.Headers['Operation-Location'])

# Create the header for the REST GET with only the subscription key
$resultHeaders = @{}
$resultHeaders.Add( "Ocp-Apim-Subscription-Key", $key )

# Get the results
# Continue to request results until the analysis is "succeeded"
Write-Host "Getting results..."
Do {
    $result = Invoke-RestMethod -Method Get `
            -Uri $resultUrl `
            -Headers $resultHeaders | ConvertTo-Json -Depth 10

    $analysis = ($result | ConvertFrom-Json)
} while ($analysis.status -ne "succeeded")
Write-Host "...Done`n"

# Access the relevant fields from the analysis
$extraction = $result | ConvertFrom-Json
#$docs = $extraction.tasks.customEntityRecognitionTasks[0].results.documents
$docs = $extraction.tasks.items[0].results.documents

# Output response if desired
if ($verbose) {
    Write-Host("GET JSON Response:`n$result`n")
}

for (($idx = 0); $idx -lt $docs.Length; $idx++) {
    $item = $docs[$idx] 
    Write-Host ("Document #", ($idx+1))
    $entities = $item.entities
    foreach ($entity in $entities) {
        Write-Host ("  - Entity Category: $($entity.category)")
        Write-Host ("  - Entity Text:  $($entity.text)")
        Write-Host ("  - Confidence:  $($entity.confidenceScore)`n")
    }   
}

Variable not defined error in Create a Question Answering Solution exercise (02-qna)

When going through the Add code to the application in Create a Question Answering Solution exercise, the variables ai_project_name and ai_deployment_name don't exist because in the given qna-app.py file the config variables are currently defined as project_name and deployment_name.

image
https://github.com/MicrosoftLearning/mslearn-ai-language/blob/main/Instructions/Exercises/02-qna.md

image
https://github.com/MicrosoftLearning/mslearn-ai-language/blob/main/Labfiles/02-qna/Python/qna-app/qna-app.py

Need to update the config variables in the qna-app.py.

Issue with lab file 04-text-classification/classify-text.ps1

For the lab: 04-text-classification/classify-text.ps1, it seems the request URI and the request is not aligned with the schema. Suggested code is provided as follows:

$key="<YOUR-KEY>"
$endpoint="<YOUR-ENDPOINT>"
$projectName = "ClassifyLab"
$deploymentName = "articles"
$verbose = $true

# Set up headers for API call
$headers = @{}
$headers.add("Ocp-Apim-Subscription-Key", $key)
$headers.add("Content-Type","application/json")

# Get text to classify
$text_file = "test1.txt"
if ($args.count -gt 0)
{
    $text_file = $args[0]
}

try {
    $contents = get-content .\$text_file -raw -ErrorAction Stop
}
catch {
    Write-Host "`nError reading provided file, please verify file exists`n"
    Exit
}

# Build body of for API call
$data = @{
    "displayName" = "Classifying documents"
    "tasks" = @(
        @{
            "kind" = "CustomSingleLabelClassification"
            "taskName" = "Single Classification Label"
            "parameters"= @{
                        "projectName" = $projectName
                        "deploymentName" = $deploymentName
                    }
        }
    )
    "analysisInput" = @{
        "documents" = @(
            @{
                "id" = "document_singleClassification"
                "language" = "en-us"
                "text" = $contents
            }
        )
    }
} | ConvertTo-Json -Depth 10

# Post text for classification
Write-Host("`n***Submitting text classification task***")


$response = Invoke-WebRequest -Method Post `
          -Uri "$($endpoint)language/analyze-text/jobs?api-version=2022-05-01" `
          -Headers $headers `
          -Body $data

# Output response if desired
if ($verbose) {
    Write-Host("`nResponse header:$($response.Headers['Operation-Location'])`n")
}

# Extract the URL from the response
# to call the API to getting the analysis results
$resultUrl = $($response.Headers['Operation-Location'])

# Create the header for the REST GET with only the subscription key
$resultHeaders = @{}
$resultHeaders.Add( "Ocp-Apim-Subscription-Key", $key )

# Get the results
# Continue to request results until the analysis is "succeeded"
Write-Host "Getting results..."
Do {
    $result = Invoke-RestMethod -Method Get `
            -Uri $resultUrl `
            -Headers $resultHeaders | ConvertTo-Json -Depth 10

    $analysis = ($result | ConvertFrom-Json)
} while ($analysis.status -ne "succeeded")
Write-Host "...Done`n"

# Access the relevant fields from the analysis
$classification = $result | ConvertFrom-Json
#$docs = $classification.tasks.customSingleClassificationTasks[0].results.documents
$docs = $classification.tasks.items[0].results.documents

# Output response if desired
if ($verbose) {
    Write-Host("GET JSON Response:`n$result`n")
}

# Output response if desired
if ($verbose) {
    Write-Host("GET JSON Response:`n$result`n")
}

for (($idx = 0); $idx -lt $docs.Length; $idx++) {
    $item = $docs[$idx] 
    Write-Host ("Document #", ($idx+1))
    Write-Host ("  - Predicted Category: ", $($item.class.category))
    Write-Host ("  - Confidence: ",$($item.class.confidenceScore))
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.