SlideShare a Scribd company logo
Schematron And
Artificial Intelligence
© 2023 Syncro Soft SRL. All rights reserved
Octavian Nadolu, Syncro Soft
octavian_nadolu@oxygenxml.com
@OctavianNadolu
AI in Schematron and SQF
AI in Schematron and SQF
Agenda
● Artificial Intelligence (AI)
● OpenAI/Generative Pre-trained Transformer
● Schematron and Schematron Quick Fixes (SQF)
● Implementing AI in Schematron and SQF
● Examples of AI-driven Schematron and SQF
Solutions
● Benefits of Using AI in Schematron and SQF
AI in Schematron and SQF
AI in Schematron and SQF
What is Artificial Intelligence?
Artificial Intelligence (AI) is a branch of computer
science dealing with the simulation of intelligent
behavior in computers.
AI in Schematron and SQF
AI in Schematron and SQF
Artificial Intelligence History
● AI history dates back to ancient times
● In 1950s AI began to take shape - researchers
began to use computers to try and simulate
human intelligence
● AI program by mathematician Alan Turing
● Expert system by Edward Feigenbaum in the
1970s and the emergence of neural networks
in the 1980s
● Today, AI is used to automate processes,
improve efficiency, and solve complex
problems
AI in Schematron and SQF
AI in Schematron and SQF
AI in Natural Language Processing
● Natural language processing is a subfield of AI that focuses
on enabling machines to understand and generate human
language
● Machine learning involves training algorithms to learn
patterns in data
● Deep learning is a type of machine learning that uses neural
networks
AI in Schematron and SQF
AI in Schematron and SQF
Generative Pre-trained Transformer(GPT)
● Network models that uses the transformer architecture
● A type of LLM (Large Language Model)
● Pre-trained refers to the model being trained on a large corpus of data
● An application is ChatGPT developed by OpenAI
AI in Schematron and SQF
AI in Schematron and SQF
Transformers
● A transformer is a deep learning model architecture used for
processing data
● The transformer architecture is based on the idea of self-attention
● Introduced in a research paper titled "Attention Is All You Need" in
2017
AI in Schematron and SQF
AI in Schematron and SQF
Embeddings
● A mathematical representations of words, sentences, or documents in
a continuous vector space
● Encode similar words with similar embeddings
● Embeddings have become a fundamental component of many NLP
tasks
AI in Schematron and SQF
AI in Schematron and SQF
OpenAI
OpenAI is an open-source research organization that works to advance
artificial intelligence (AI)
AI in Schematron and SQF
AI in Schematron and SQF
OpenAI Application
OpenAI has trained language models that are very good at understanding
and generating text
● Text Summarization
● Natural Language Processing
● Text Generation
● Machine Translation
● Text Classification
AI in Schematron and SQF
AI in Schematron and SQF
What is Schematron?
A language for making assertions in documents
AI in Schematron and SQF
AI in Schematron and SQF
Schematron and AI
Automatically verify documents using an AI model
Examples of verification with AI:
– Is active/passive voice used in the description?
– Is this written according to the style guide?
– Does the topic answers to this <question>?
– Is spelling and grammar correct?
AI in Schematron and SQF
AI in Schematron and SQF
Schematron Quick Fix (SQF)
● SQF is an extension of the ISO Schematron
● User-defined fixes for Schematron assert/report
AI in Schematron and SQF
AI in Schematron and SQF
SQF and AI
● Correct problems in documents using AI
● Examples:
– Rephrase to use active voice
– Rephrase to have 20 words
– Rephrase paragraph to answer to the following question
– Correct spelling and grammar
AI in Schematron and SQF
AI in Schematron and SQF
Implementation of AI in Schematron
● Using XSLT functions
● Using extension functions
– xs:string ai:transform-content(xs:string instruction, xs:string content)
– xs:boolean ai:verify-content(xs:string instruction, xs:string content)
<xsl:function name="ai:chatGPT">
<xsl:param name="userInput"/>
<xsl:variable name="url" select="'https://api.chatgpt.com/v1/chatbot/question'"/>
<xsl:variable name="requestBody" select="concat('{', '&quot;text&quot;:&quot;',
$userInput,'&quot;', '}')"/>
<xsl:variable name="response" select="document(concat($url, '?apiKey=',
'&lt;your_api_key>'))//response"/>
<xsl:sequence select="$response"/>
…..
</xsl:function>
AI in Schematron and SQF
AI in Schematron and SQF
Functions Built-in Prompt
● A prompt represents instructions and context given to a language
model to perform a task
● Functions can provide a specific built-in prompt
– ai:verify-content()
“You are a technical writer and you need to verify the following and respond with
true or false:“ + Is active voice used in the description? + content
– ai:transform-content()
“You are a developer and you need perform the following task:“ + Rephrase
to use active voice + content
https://github.com/f/awesome-chatgpt-prompts
AI in Schematron and SQF
AI in Schematron and SQF
Examples of Schematron Rules
AI in Schematron and SQF
AI in Schematron and SQF
Check if the text is consistent
● Example of a rule that checks if the text is easy to read and understand
The text in not easy to read and understand
AI in Schematron and SQF
AI in Schematron and SQF
Check if the text is consistent
● Rule that verifies if the text is easy to read and understand
<sch:rule context="p">
<sch:assert test="ai:verify-content('Is the text easy to read and understand?', .)">
The text in not easy to read and understand</sch:assert>
</sch:rule>
AI in Schematron and SQF
AI in Schematron and SQF
Correct text consistency
● Example fix that makes the text easy to read and understand
Correct the consistency of the text
AI in Schematron and SQF
AI in Schematron and SQF
Correct the text consistency
● SQF fix that corrects the text to be easy to read and understand
<sqf:fix id="rephrase">
<sqf:description>
<sqf:title>Correct the consistency of the text</sqf:title>
</sqf:description>
<sqf:replace match="text()" select="ai:transform-content(
'Correct the text to be easy to read and understand', .)"/>
</sqf:fix>
AI in Schematron and SQF
AI in Schematron and SQF
Check the text voice
● Example of a rule that checks if the text uses active voice
In the description we should use active voice
AI in Schematron and SQF
AI in Schematron and SQF
Check the text voice
● Rule that verifies if the text voice is active
<sch:rule context="shortdesc">
<sch:assert test="ai:verify-content('Is active voice used?', .)">
In the description we should use active voice.</sch:assert>
</sch:rule>
AI in Schematron and SQF
AI in Schematron and SQF
Correct the text voice
● Example fix that reformulates the text to use active voice
Reformulate the text to use active voice
AI in Schematron and SQF
AI in Schematron and SQF
Correct the text voice
● SQF fix that that reformulates the text to use active voice
<sqf:fix id="rephrase">
<sqf:description>
<sqf:title>Reformulate the text to use active voice</sqf:title>
</sqf:description>
<sqf:replace match="text()" select="ai:transform-content('
Reformulate to use active voice', .)"/>
</sqf:fix>
AI in Schematron and SQF
AI in Schematron and SQF
Answer to question
● Example of a rule that checks if the text answers a specified question
The test does not answer to the question "What is OpenAI?"
AI in Schematron and SQF
AI in Schematron and SQF
Check the question
● Rule that verifies if the text does answer a specific question
<sch:rule context="p[@id='openai']">
<sch:assert test="ai:verify-content('Does it answers to the question: What is OpenAI?', .)">
The test does not answer to the question "What is OpenAPI?" </sch:assert>
</sch:rule>
AI in Schematron and SQF
AI in Schematron and SQF
Reformulate text
● Example fix that reformulates the text to answer a specific question
Reformulate the text to answer to the question:
What is OpenAI?
AI in Schematron and SQF
AI in Schematron and SQF
Reformulate text
● SQF fix that that reformulates the text to answer the
question “What is OpenAI?”
<sqf:fix id="rephrase">
<sqf:description>
<sqf:title>Reformulate the text to answer to the question:
What is OpenAI?</sqf:title>
</sqf:description>
<sqf:replace match="text()" select="ai:transform-content(
'Reformulate the text to answer to the question: What is OpenAI?', .)"/>
</sqf:fix>
AI in Schematron and SQF
AI in Schematron and SQF
AI and Schematron
● Advantages of using AI with Schematron
– Verify your documents using AI power
– Define the instructions to be sent to the AI engine
– Control the content to be verified
– Control the content that is sent
– Automation of the process
● Challenges
– High cost for validation as you type or multiple validations
– The response from the AI server in not instant
– Responses can sometimes be inaccurate
AI in Schematron and SQF
AI in Schematron and SQF
AI and Schematron Quick Fixes
● Advantages of using AI with SQF
– Use the power of AI to correct the content
– Control the content that is sent
– Control the content to be modified
– Automation of the process
● Challenges
– The response from the AI server is not instant
– Responses can sometimes be inaccurate
AI in Schematron and SQF
AI in Schematron and SQF
AI and Schematron Quick Fixes
● Use AI just to correct the problems
– Reduce the cost
– You can use the validation as you type
– The user decides when to call the AI
AI in Schematron and SQF
AI in Schematron and SQF
Check the number of words
● Example of a rule that checks the number of words from the
description
The description must contain less than 50 words.
AI in Schematron and SQF
AI in Schematron and SQF
Check the number of words
● Rule that verifies the number of words from the shortdesc element
<sch:rule context="shortdesc">
<sch:report test="count(tokenize(.,'s+')) > 50">
The description must contain less than 50 words.</sch:report>
</sch:rule>
AI in Schematron and SQF
AI in Schematron and SQF
Correct text to contain less words
● Example fix that reformulates the phrase to contains less than 50 words
Reformulate phrase to contain less than 50 words
AI in Schematron and SQF
AI in Schematron and SQF
Correct text to contain less words
● SQF fix that reformulates the phrase to have less than 50 words
<sqf:fix id="rephrase">
<sqf:description>
<sqf:title>Reformulate phrase to contain less than 50 words</sqf:title>
</sqf:description>
<sqf:replace match="text()" select="ai:transform-content(
'Reformulate phrase to contain less than 50 words', .)"/>
</sqf:fix>
AI in Schematron and SQF
AI in Schematron and SQF
Check if text should be a list
● Example of a rule that checks it the text should be converted to a list
The text should be converted to a list.
<body>
<p> - Is active/passive voice used in the description?
- Is this written according to the styleguide?
- Does the to pic answers to this "question"?
- Is spelling and grammar correct?</p>
</body>
AI in Schematron and SQF
AI in Schematron and SQF
Check if text should be a list
● Rule that verifies the text from a paragraph should be converted to a
list
<sch:rule context="p">
<sch:report test="contains(., '- ')">
The text should be converted to a list</sch:report>
</sch:rule>
AI in Schematron and SQF
AI in Schematron and SQF
Create a list from phrases
● Example of fix that generates an unordered list from a set of phrases
Create a list from the phrases from the paragraph
<p> - Is active/passive voice used in the description?
- Is this written according to the styleguide?
- Does the to pic answers to this "question"?
- Is spelling and grammar correct?</p>
<ul>
<li>Active/passive voice used?</li>
<li>Written according to styleguide?</li>
<li>Topic answers question?</li>
<li>Spelling and grammar correct?</li>
</ul>
AI in Schematron and SQF
AI in Schematron and SQF
Create a list from phrases
● SQF fix that creates a list from a set of phrases
<sqf:fix id="replace">
<sqf:description>
<sqf:title>Create a list from the phrases from the paragraph</sqf:title>
</sqf:description>
<sqf:replace match="text()">
<xsl:value-of select="ai:transform-content(
'Create a Dita unorderd list with an item from each phrase', .)"
disable-output-escaping="yes"/>
</sqf:replace>
</sqf:fix>
AI in Schematron and SQF
AI in Schematron and SQF
User Entry
The instruction to correct the problem
is specified by the user
AI in Schematron and SQF
AI in Schematron and SQF
Check technical terms
● Example of a rule that checks if the technical terms are not explained
adequately
The text uses technical terms that are not explained adequately
AI in Schematron and SQF
AI in Schematron and SQF
Check technical terms
● Rule that verifies if the technical terms are explained adequately
<sch:report test="ai:verify-content('Are the technical terms explained ambiguous?', .)"
The text uses technical terms that are not explained adequately.</sch:report>
AI in Schematron and SQF
AI in Schematron and SQF
Correct terms
● Example fix that allows the user to specify how to reformulate the
phrase
Specify how to reformulate the phrase
AI in Schematron and SQF
AI in Schematron and SQF
Correct terms
● SQF fix that allows the user to specify the prompt that will be sent to
the AI
<sqf:fix id="reformulateUser">
<sqf:description>
<sqf:title>Specify how to reformulate the phrase</sqf:title>
</sqf:description>
<sqf:user-entry name="userInput" default="'
Reformulate phrase and replace the ambiguous terms with a more accurate one'">
<sqf:description><sqf:title>How to correct:</sqf:title>sqf:description>
</sqf:user-entry>
<sqf:replace match="text()" select="ai:transform-content($userInput, .)"/>
</sqf:fix>
AI in Schematron and SQF
AI in Schematron and SQF
Generate AI Fix
● Generate the fix from the Schematron message
● Uses the Schematron rule context as the content to correct
– System prompt: Act as a developer. Perform the following task:
The description must contain less than 50 words
– User prompt: The content from the “shortdesc” element
– Operation: Replace the text from “shortdesc” with the one from AI
<sch:rule context="shortdesc">
<sch:report test="count(tokenize(.,'s+')) > 50">
The description must contain less than 50 words.</sch:report>
</sch:rule>
Generate AI Fix
AI in Schematron and SQF
AI in Schematron and SQF
Automatic Fix
● Advantages:
– No need to create fixes in Schematron
– A fix is generated automatically from each Schematron message
– Fixes can also be generated for other error messages
● Challenges
– The message need to be as concise as possible so that the AI can use
– Sometimes you need to change the context for the fix or perform different
operations
AI in Schematron and SQF
AI in Schematron and SQF
Create Schematron using AI
● An assert that verifies the number of words to be 10
● An assert that verifies if there is an email in text
<sch:assert test="count(tokenize(., 's+')) = 10">There should be exactly 10.</sch:assert>
<sch:assert test="matches(., 'b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Z|a-z]{2,}b')">
There is no email in the text</sch:assert>
AI
AI
AI in Schematron and SQF
AI in Schematron and SQF
Conclusion
● Schematron can use the power of AI to verify content
● Correct content using SQF and AI
● Generate fixes automatically using AI
● Develop Schematron with AI
● AI constantly improving and growing
AI in Schematron and SQF
AI in Schematron and SQF
Resources
● https://openai.com/
● https://platform.openai.com/docs/guides/chat
● http://schematron.com/
● http://schematron-quickfix.github.io/sqf
Questions?
Octavian Nadolu
Project Manager at Syncro Soft
octavian.nadolu@oxygenxml.com
Twitter: @OctavianNadolu
LinkedIn: octaviannadolu

More Related Content

PDF
Verify Content With Artificial Intelligence
PDF
Artificia Intellicence and XPath Extension Functions
PDF
Schematron 2016 and SQF Update
PDF
XML Quick Fixes
PDF
The Power Of Schematron Quick Fixes - XML Prague 2019
PDF
Schematron & SQF In oXygen
PDF
Schematron QuickFix
PPTX
2024-11-28 - Mastering Logic Apps Workflows.pptx
Verify Content With Artificial Intelligence
Artificia Intellicence and XPath Extension Functions
Schematron 2016 and SQF Update
XML Quick Fixes
The Power Of Schematron Quick Fixes - XML Prague 2019
Schematron & SQF In oXygen
Schematron QuickFix
2024-11-28 - Mastering Logic Apps Workflows.pptx

Similar to Leveraging the Power of AI and Schematron for Content Verification and Correction (20)

PDF
Tech talk specflow_bddx_hassa_nagy
PDF
Operationalize Apache Spark Analytics
PPTX
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
ODP
FluentSelenium Presentation Code Camp09
PDF
Swagger With REST APIs.pptx.pdf
PPT
JSP-Servlet.ppt
PDF
JSP-Servlet+Advance+java+web-service.pdf
PDF
IBM WebSphere DataPower Training.pdf
PPTX
Ladies Be Architects - Apex Basics
PDF
What's New in IBM Java 8 SE?
PPTX
Interactive Java Support to your tool -- The JShell API and Architecture
PPT
Struts2-Spring=Hibernate
DOCX
Himansu-Java&BigdataDeveloper
PPTX
JavaScript, VBScript, AJAX, CGI
PPTX
Natural Language to SQL Query conversion using Machine Learning Techniques on...
PDF
A Tool For Big Data Analysis using Apache Spark
PPTX
cloud_content useful for engineering stu
PDF
Writing an Interactive Interface for SQL on Flink
DOC
Sunil sharanappa senior automation test engineer profile
PPTX
SWOFT a PHP Microservice Framework - 2020
Tech talk specflow_bddx_hassa_nagy
Operationalize Apache Spark Analytics
Test Automation - Presented by Nagarajan, Architect @ TechCafe-2014
FluentSelenium Presentation Code Camp09
Swagger With REST APIs.pptx.pdf
JSP-Servlet.ppt
JSP-Servlet+Advance+java+web-service.pdf
IBM WebSphere DataPower Training.pdf
Ladies Be Architects - Apex Basics
What's New in IBM Java 8 SE?
Interactive Java Support to your tool -- The JShell API and Architecture
Struts2-Spring=Hibernate
Himansu-Java&BigdataDeveloper
JavaScript, VBScript, AJAX, CGI
Natural Language to SQL Query conversion using Machine Learning Techniques on...
A Tool For Big Data Analysis using Apache Spark
cloud_content useful for engineering stu
Writing an Interactive Interface for SQL on Flink
Sunil sharanappa senior automation test engineer profile
SWOFT a PHP Microservice Framework - 2020
Ad

More from Octavian Nadolu (20)

PDF
Artificial Intelligence for XMLDevelopment
PDF
YAML Editing and Validation In Oxygen
PDF
Oxygen JSON Editor
PDF
OpenAPI/AsyncAPI Support in Oxygen
PDF
Validating XML and JSON Documents Using Oxygen Scripting
PDF
OpenAPI Editing, Testing, and Documenting
PDF
JSON, JSON Schema, and OpenAPI
PDF
Create an Design JSON Schema
PDF
Compare And Merge Scripts
PDF
JSON Schema Design
PDF
Schematron For Non-XML Languages
PDF
JSON and JSON Schema in Oxygen
PDF
HTML5 Editing Validation
PDF
Documentation Quality Assurance with ISO Schematron
PDF
Introduction to Schematron
PDF
Hands on JSON
ODP
JSON Edit, Validate, Query, Transform, and Convert
PDF
Collaboration Tools to Help Improve Documentation Process
ODP
Schematron step-by-step
PDF
Exploring the new features in Oxygen XML Editor 20 - Development
Artificial Intelligence for XMLDevelopment
YAML Editing and Validation In Oxygen
Oxygen JSON Editor
OpenAPI/AsyncAPI Support in Oxygen
Validating XML and JSON Documents Using Oxygen Scripting
OpenAPI Editing, Testing, and Documenting
JSON, JSON Schema, and OpenAPI
Create an Design JSON Schema
Compare And Merge Scripts
JSON Schema Design
Schematron For Non-XML Languages
JSON and JSON Schema in Oxygen
HTML5 Editing Validation
Documentation Quality Assurance with ISO Schematron
Introduction to Schematron
Hands on JSON
JSON Edit, Validate, Query, Transform, and Convert
Collaboration Tools to Help Improve Documentation Process
Schematron step-by-step
Exploring the new features in Oxygen XML Editor 20 - Development
Ad

Recently uploaded (20)

PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Nekopoi APK 2025 free lastest update
PPTX
assetexplorer- product-overview - presentation
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Download FL Studio Crack Latest version 2025 ?
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
Cost to Outsource Software Development in 2025
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Why Generative AI is the Future of Content, Code & Creativity?
Advanced SystemCare Ultimate Crack + Portable (2025)
Nekopoi APK 2025 free lastest update
assetexplorer- product-overview - presentation
Oracle Fusion HCM Cloud Demo for Beginners
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
wealthsignaloriginal-com-DS-text-... (1).pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Choose the Right IT Partner for Your Business in Malaysia
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Autodesk AutoCAD Crack Free Download 2025
AutoCAD Professional Crack 2025 With License Key
Odoo Companies in India – Driving Business Transformation.pdf
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Download FL Studio Crack Latest version 2025 ?
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Monitoring Stack: Grafana, Loki & Promtail
Cost to Outsource Software Development in 2025

Leveraging the Power of AI and Schematron for Content Verification and Correction

  • 1. Schematron And Artificial Intelligence © 2023 Syncro Soft SRL. All rights reserved Octavian Nadolu, Syncro Soft octavian_nadolu@oxygenxml.com @OctavianNadolu
  • 2. AI in Schematron and SQF AI in Schematron and SQF Agenda ● Artificial Intelligence (AI) ● OpenAI/Generative Pre-trained Transformer ● Schematron and Schematron Quick Fixes (SQF) ● Implementing AI in Schematron and SQF ● Examples of AI-driven Schematron and SQF Solutions ● Benefits of Using AI in Schematron and SQF
  • 3. AI in Schematron and SQF AI in Schematron and SQF What is Artificial Intelligence? Artificial Intelligence (AI) is a branch of computer science dealing with the simulation of intelligent behavior in computers.
  • 4. AI in Schematron and SQF AI in Schematron and SQF Artificial Intelligence History ● AI history dates back to ancient times ● In 1950s AI began to take shape - researchers began to use computers to try and simulate human intelligence ● AI program by mathematician Alan Turing ● Expert system by Edward Feigenbaum in the 1970s and the emergence of neural networks in the 1980s ● Today, AI is used to automate processes, improve efficiency, and solve complex problems
  • 5. AI in Schematron and SQF AI in Schematron and SQF AI in Natural Language Processing ● Natural language processing is a subfield of AI that focuses on enabling machines to understand and generate human language ● Machine learning involves training algorithms to learn patterns in data ● Deep learning is a type of machine learning that uses neural networks
  • 6. AI in Schematron and SQF AI in Schematron and SQF Generative Pre-trained Transformer(GPT) ● Network models that uses the transformer architecture ● A type of LLM (Large Language Model) ● Pre-trained refers to the model being trained on a large corpus of data ● An application is ChatGPT developed by OpenAI
  • 7. AI in Schematron and SQF AI in Schematron and SQF Transformers ● A transformer is a deep learning model architecture used for processing data ● The transformer architecture is based on the idea of self-attention ● Introduced in a research paper titled "Attention Is All You Need" in 2017
  • 8. AI in Schematron and SQF AI in Schematron and SQF Embeddings ● A mathematical representations of words, sentences, or documents in a continuous vector space ● Encode similar words with similar embeddings ● Embeddings have become a fundamental component of many NLP tasks
  • 9. AI in Schematron and SQF AI in Schematron and SQF OpenAI OpenAI is an open-source research organization that works to advance artificial intelligence (AI)
  • 10. AI in Schematron and SQF AI in Schematron and SQF OpenAI Application OpenAI has trained language models that are very good at understanding and generating text ● Text Summarization ● Natural Language Processing ● Text Generation ● Machine Translation ● Text Classification
  • 11. AI in Schematron and SQF AI in Schematron and SQF What is Schematron? A language for making assertions in documents
  • 12. AI in Schematron and SQF AI in Schematron and SQF Schematron and AI Automatically verify documents using an AI model Examples of verification with AI: – Is active/passive voice used in the description? – Is this written according to the style guide? – Does the topic answers to this <question>? – Is spelling and grammar correct?
  • 13. AI in Schematron and SQF AI in Schematron and SQF Schematron Quick Fix (SQF) ● SQF is an extension of the ISO Schematron ● User-defined fixes for Schematron assert/report
  • 14. AI in Schematron and SQF AI in Schematron and SQF SQF and AI ● Correct problems in documents using AI ● Examples: – Rephrase to use active voice – Rephrase to have 20 words – Rephrase paragraph to answer to the following question – Correct spelling and grammar
  • 15. AI in Schematron and SQF AI in Schematron and SQF Implementation of AI in Schematron ● Using XSLT functions ● Using extension functions – xs:string ai:transform-content(xs:string instruction, xs:string content) – xs:boolean ai:verify-content(xs:string instruction, xs:string content) <xsl:function name="ai:chatGPT"> <xsl:param name="userInput"/> <xsl:variable name="url" select="'https://api.chatgpt.com/v1/chatbot/question'"/> <xsl:variable name="requestBody" select="concat('{', '&quot;text&quot;:&quot;', $userInput,'&quot;', '}')"/> <xsl:variable name="response" select="document(concat($url, '?apiKey=', '&lt;your_api_key>'))//response"/> <xsl:sequence select="$response"/> ….. </xsl:function>
  • 16. AI in Schematron and SQF AI in Schematron and SQF Functions Built-in Prompt ● A prompt represents instructions and context given to a language model to perform a task ● Functions can provide a specific built-in prompt – ai:verify-content() “You are a technical writer and you need to verify the following and respond with true or false:“ + Is active voice used in the description? + content – ai:transform-content() “You are a developer and you need perform the following task:“ + Rephrase to use active voice + content https://github.com/f/awesome-chatgpt-prompts
  • 17. AI in Schematron and SQF AI in Schematron and SQF Examples of Schematron Rules
  • 18. AI in Schematron and SQF AI in Schematron and SQF Check if the text is consistent ● Example of a rule that checks if the text is easy to read and understand The text in not easy to read and understand
  • 19. AI in Schematron and SQF AI in Schematron and SQF Check if the text is consistent ● Rule that verifies if the text is easy to read and understand <sch:rule context="p"> <sch:assert test="ai:verify-content('Is the text easy to read and understand?', .)"> The text in not easy to read and understand</sch:assert> </sch:rule>
  • 20. AI in Schematron and SQF AI in Schematron and SQF Correct text consistency ● Example fix that makes the text easy to read and understand Correct the consistency of the text
  • 21. AI in Schematron and SQF AI in Schematron and SQF Correct the text consistency ● SQF fix that corrects the text to be easy to read and understand <sqf:fix id="rephrase"> <sqf:description> <sqf:title>Correct the consistency of the text</sqf:title> </sqf:description> <sqf:replace match="text()" select="ai:transform-content( 'Correct the text to be easy to read and understand', .)"/> </sqf:fix>
  • 22. AI in Schematron and SQF AI in Schematron and SQF Check the text voice ● Example of a rule that checks if the text uses active voice In the description we should use active voice
  • 23. AI in Schematron and SQF AI in Schematron and SQF Check the text voice ● Rule that verifies if the text voice is active <sch:rule context="shortdesc"> <sch:assert test="ai:verify-content('Is active voice used?', .)"> In the description we should use active voice.</sch:assert> </sch:rule>
  • 24. AI in Schematron and SQF AI in Schematron and SQF Correct the text voice ● Example fix that reformulates the text to use active voice Reformulate the text to use active voice
  • 25. AI in Schematron and SQF AI in Schematron and SQF Correct the text voice ● SQF fix that that reformulates the text to use active voice <sqf:fix id="rephrase"> <sqf:description> <sqf:title>Reformulate the text to use active voice</sqf:title> </sqf:description> <sqf:replace match="text()" select="ai:transform-content(' Reformulate to use active voice', .)"/> </sqf:fix>
  • 26. AI in Schematron and SQF AI in Schematron and SQF Answer to question ● Example of a rule that checks if the text answers a specified question The test does not answer to the question "What is OpenAI?"
  • 27. AI in Schematron and SQF AI in Schematron and SQF Check the question ● Rule that verifies if the text does answer a specific question <sch:rule context="p[@id='openai']"> <sch:assert test="ai:verify-content('Does it answers to the question: What is OpenAI?', .)"> The test does not answer to the question "What is OpenAPI?" </sch:assert> </sch:rule>
  • 28. AI in Schematron and SQF AI in Schematron and SQF Reformulate text ● Example fix that reformulates the text to answer a specific question Reformulate the text to answer to the question: What is OpenAI?
  • 29. AI in Schematron and SQF AI in Schematron and SQF Reformulate text ● SQF fix that that reformulates the text to answer the question “What is OpenAI?” <sqf:fix id="rephrase"> <sqf:description> <sqf:title>Reformulate the text to answer to the question: What is OpenAI?</sqf:title> </sqf:description> <sqf:replace match="text()" select="ai:transform-content( 'Reformulate the text to answer to the question: What is OpenAI?', .)"/> </sqf:fix>
  • 30. AI in Schematron and SQF AI in Schematron and SQF AI and Schematron ● Advantages of using AI with Schematron – Verify your documents using AI power – Define the instructions to be sent to the AI engine – Control the content to be verified – Control the content that is sent – Automation of the process ● Challenges – High cost for validation as you type or multiple validations – The response from the AI server in not instant – Responses can sometimes be inaccurate
  • 31. AI in Schematron and SQF AI in Schematron and SQF AI and Schematron Quick Fixes ● Advantages of using AI with SQF – Use the power of AI to correct the content – Control the content that is sent – Control the content to be modified – Automation of the process ● Challenges – The response from the AI server is not instant – Responses can sometimes be inaccurate
  • 32. AI in Schematron and SQF AI in Schematron and SQF AI and Schematron Quick Fixes ● Use AI just to correct the problems – Reduce the cost – You can use the validation as you type – The user decides when to call the AI
  • 33. AI in Schematron and SQF AI in Schematron and SQF Check the number of words ● Example of a rule that checks the number of words from the description The description must contain less than 50 words.
  • 34. AI in Schematron and SQF AI in Schematron and SQF Check the number of words ● Rule that verifies the number of words from the shortdesc element <sch:rule context="shortdesc"> <sch:report test="count(tokenize(.,'s+')) > 50"> The description must contain less than 50 words.</sch:report> </sch:rule>
  • 35. AI in Schematron and SQF AI in Schematron and SQF Correct text to contain less words ● Example fix that reformulates the phrase to contains less than 50 words Reformulate phrase to contain less than 50 words
  • 36. AI in Schematron and SQF AI in Schematron and SQF Correct text to contain less words ● SQF fix that reformulates the phrase to have less than 50 words <sqf:fix id="rephrase"> <sqf:description> <sqf:title>Reformulate phrase to contain less than 50 words</sqf:title> </sqf:description> <sqf:replace match="text()" select="ai:transform-content( 'Reformulate phrase to contain less than 50 words', .)"/> </sqf:fix>
  • 37. AI in Schematron and SQF AI in Schematron and SQF Check if text should be a list ● Example of a rule that checks it the text should be converted to a list The text should be converted to a list. <body> <p> - Is active/passive voice used in the description? - Is this written according to the styleguide? - Does the to pic answers to this "question"? - Is spelling and grammar correct?</p> </body>
  • 38. AI in Schematron and SQF AI in Schematron and SQF Check if text should be a list ● Rule that verifies the text from a paragraph should be converted to a list <sch:rule context="p"> <sch:report test="contains(., '- ')"> The text should be converted to a list</sch:report> </sch:rule>
  • 39. AI in Schematron and SQF AI in Schematron and SQF Create a list from phrases ● Example of fix that generates an unordered list from a set of phrases Create a list from the phrases from the paragraph <p> - Is active/passive voice used in the description? - Is this written according to the styleguide? - Does the to pic answers to this "question"? - Is spelling and grammar correct?</p> <ul> <li>Active/passive voice used?</li> <li>Written according to styleguide?</li> <li>Topic answers question?</li> <li>Spelling and grammar correct?</li> </ul>
  • 40. AI in Schematron and SQF AI in Schematron and SQF Create a list from phrases ● SQF fix that creates a list from a set of phrases <sqf:fix id="replace"> <sqf:description> <sqf:title>Create a list from the phrases from the paragraph</sqf:title> </sqf:description> <sqf:replace match="text()"> <xsl:value-of select="ai:transform-content( 'Create a Dita unorderd list with an item from each phrase', .)" disable-output-escaping="yes"/> </sqf:replace> </sqf:fix>
  • 41. AI in Schematron and SQF AI in Schematron and SQF User Entry The instruction to correct the problem is specified by the user
  • 42. AI in Schematron and SQF AI in Schematron and SQF Check technical terms ● Example of a rule that checks if the technical terms are not explained adequately The text uses technical terms that are not explained adequately
  • 43. AI in Schematron and SQF AI in Schematron and SQF Check technical terms ● Rule that verifies if the technical terms are explained adequately <sch:report test="ai:verify-content('Are the technical terms explained ambiguous?', .)" The text uses technical terms that are not explained adequately.</sch:report>
  • 44. AI in Schematron and SQF AI in Schematron and SQF Correct terms ● Example fix that allows the user to specify how to reformulate the phrase Specify how to reformulate the phrase
  • 45. AI in Schematron and SQF AI in Schematron and SQF Correct terms ● SQF fix that allows the user to specify the prompt that will be sent to the AI <sqf:fix id="reformulateUser"> <sqf:description> <sqf:title>Specify how to reformulate the phrase</sqf:title> </sqf:description> <sqf:user-entry name="userInput" default="' Reformulate phrase and replace the ambiguous terms with a more accurate one'"> <sqf:description><sqf:title>How to correct:</sqf:title>sqf:description> </sqf:user-entry> <sqf:replace match="text()" select="ai:transform-content($userInput, .)"/> </sqf:fix>
  • 46. AI in Schematron and SQF AI in Schematron and SQF Generate AI Fix ● Generate the fix from the Schematron message ● Uses the Schematron rule context as the content to correct – System prompt: Act as a developer. Perform the following task: The description must contain less than 50 words – User prompt: The content from the “shortdesc” element – Operation: Replace the text from “shortdesc” with the one from AI <sch:rule context="shortdesc"> <sch:report test="count(tokenize(.,'s+')) > 50"> The description must contain less than 50 words.</sch:report> </sch:rule> Generate AI Fix
  • 47. AI in Schematron and SQF AI in Schematron and SQF Automatic Fix ● Advantages: – No need to create fixes in Schematron – A fix is generated automatically from each Schematron message – Fixes can also be generated for other error messages ● Challenges – The message need to be as concise as possible so that the AI can use – Sometimes you need to change the context for the fix or perform different operations
  • 48. AI in Schematron and SQF AI in Schematron and SQF Create Schematron using AI ● An assert that verifies the number of words to be 10 ● An assert that verifies if there is an email in text <sch:assert test="count(tokenize(., 's+')) = 10">There should be exactly 10.</sch:assert> <sch:assert test="matches(., 'b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Z|a-z]{2,}b')"> There is no email in the text</sch:assert> AI AI
  • 49. AI in Schematron and SQF AI in Schematron and SQF Conclusion ● Schematron can use the power of AI to verify content ● Correct content using SQF and AI ● Generate fixes automatically using AI ● Develop Schematron with AI ● AI constantly improving and growing
  • 50. AI in Schematron and SQF AI in Schematron and SQF Resources ● https://openai.com/ ● https://platform.openai.com/docs/guides/chat ● http://schematron.com/ ● http://schematron-quickfix.github.io/sqf
  • 51. Questions? Octavian Nadolu Project Manager at Syncro Soft octavian.nadolu@oxygenxml.com Twitter: @OctavianNadolu LinkedIn: octaviannadolu