SlideShare a Scribd company logo
1 of 63
Download to read offline
Anatoly Belikov
abelikov@singularitynet.io
Introduction to
OpenCog
2
$ https://github.com/singnet/
opencog-workshops
$
3
CogPrime
4
CogPrime
5
Use cases
• Chatbots
• Bioinformatics
• Unsupervised language learning
• Visual Question Answering VQA
• …
6
Atomspace - graph database
Hypergraph database designed to be primarily used as a
storage of explicit, declarative knowledge
Hypergraph defines programming language - Atomese
Has a number of associated mechanisms:
pattern matching, unified rule engine, moses
7
Types of data in atomspace: Atoms
Atom
LinkNode
8
Types of data in atomspace: Values
StringValue LinkValueFloatValue
TruthValue
9
Atomspace - API introduction
Python:
>> from opencog.atomspace import AtomSpace, types
>> atomspace = AtomSpace()
Scheme:
scheme> (use-modules (opencog))
scheme> (define atomspace (cog-new-atomspace))
10
Pattern matcher examples
$ docker run -p8888:8888  -it demo-opencog
/home/relex/opencog-intro-master/
notebook.sh
$ http://localhost:8888/notebooks/and-
link-example.ipynb
11
Loading and storing
Load scheme file from scheme or python:
>> scheme_eval(atomspace, '(load-from-path “atomspace.scm")')
Indexed by atom type and name
Use PostgreSQL as backend storage
12
13
14
Nodes examples
scheme@(guile-user)> (ConceptNode "Test")
scheme@(guile-user)> (VariableNode "X")
scheme@(guile-user)> (PredicateNode "is-red")
15
Links examples: ListLink
>>> lst1 = ListLink(ConceptNode("red"),
VariableNode("$X"),
ConceptNode("blue"))
>>> print(str(lst1))
(ListLink
(ConceptNode "red")
(VariableNode "$X")
(ConceptNode "blue")
)
16
TruthValue
> from opencog.atomspace import TruthValue
> tv = TruthValue(0.5, 0.92)
P(Heads) = 0.5, .3
> ConceptNode(“Heads”).tv = tv
17
18
19
BindLink and pattern matcher
BindLink

<variables> - optional

  <pattern to match>

  <rewrite term>
Pattern example:
ListLink(ConceptNode("red"),
      VariableNode("$X"),
        ConceptNode("blue"))
20
21
22
23
24
25
26
Unified Rule Engine
Inference engine based on graph rewriting rules.
Allows to perform declarative inference.
Rules and data defined in the same language - atomese
Can do backward and forward chaining
27
Unified Rule Engine
Inference in first-order logic
Automatic differentiation
Graphical models
Probabilistic logic inference
Fuzzy logic inference
...
28
29
30
Running backward chainer
> request =
InheritanceLink(ConceptNode("Socrates"),
               ConceptNode("mortal"))
> tr = AtomSpace() # trace atomspace
> rule_base = ConceptNode("PLN") # rules to use
> chainer = BackwardChainer(atomspace, rule_base,
  request,
  trace_as=tr)
> chainer.do_chain()
> print(chainer.get_results())
31
Defining problem
> InheritanceLink(ConceptNode("Socrates"),
ConceptNode("man")).tv =
TruthValue(0.97, 0.92)
> InheritanceLink(ConceptNode("man"),
ConceptNode("mortal")).tv =
TruthValue(0.98, 0.94)
InheritanceLink(ConceptNode("Socrates"),
ConceptNode("mortal")).tv = ???
32
Result
> (SetLink
(InheritanceLink (stv 0.9508 0.828)
(ConceptNode(“Socrates”),
(ConceptNode("mortal"))
33
Rule structure:
BindLink

<variables>

AndLink

<premise-1>

...

<premise-n>

<conclusion-pattern>
34
Calculate conclusion with ExecutionOutputLink
ExecutionOutputLink

GroundedSchemaNode <formula-name>

List
<conclusion-pattern>
<other arguments>
35
36
Deduction rule example
premise
A -> B
B -> C
Ergo: A -> C
condition = AndLink(BA, CB)
BA = InheritanceLink(var_b, var_a)
CB = InheritanceLink(var_c, var_b)
rewrite = ExecutionOutputLink(
GroundedSchemaNode("scm: deduction-formula"),
ListLink(CA, CB, BA))
deduction_link = BindLink(condition, rewrite)
37
38
39
40
41
42
BindLink the query was answered with
(ExecutionOutputLink
(GroundedSchemaNode "scm: deduction-formula")
(ListLink
(InheritanceLink (stv 0.9508 0.828)
(ConceptNode "Socrates")
(ConceptNode "mortal")
)
(InheritanceLink
(ConceptNode "Socrates")
(VariableNode "$B")
)
(InheritanceLink
(VariableNode "$B")
(ConceptNode "mortal")
)))
(AndLink
(InheritanceLink
(VariableNode "$B")
(ConceptNode "mortal")
)
(NotLink
(IdenticalLink
(ConceptNode "Socrates")
(ConceptNode "mortal")
)
)
(InheritanceLink
(ConceptNode "Socrates")
(VariableNode "$B")
))
43
Running VQA demo from the docker image
$ docker pull opencog/vqa
$ wget https://s3-us-west-2.amazonaws.com/
abelikov/data-small.tar.gz && tar -xvf data-
small.tar.gz
$ docker run  -v `pwd`/data:/home/relex/projects/
data -p 8889:8888 -it demo-opencog
44
45
46
47
Building VQA with OpenCog
Building blocks:
Atomspace for storing facts about world
Link-Grammar + RelEx for text processing
Faster-RCNN for bounding box and feature extraction
Our neural network models for classification
Unified rule engine and pattern matcher for computing answers
48
VQA pipeline overview
How many animals are there?
PatternMatcherVQA
(python)
atomspace
Relex + link-grammar
(java)
Pattern matcher
49
Knowledge base
atomspace
(InheritanceLink (stv 0.795 0.71)
(ConceptNode "van") (ConceptNode "vehicle"))
(InheritanceLink (stv 0.576 0.525)
(ConceptNode "van") (ConceptNode "auto"))
50
VQA pipeline: text processing
sentence => link-grammar => relex => template => query
51
Taking a look at link-grammar
linkparser> How many zebras are there?
Found 22 linkages (6 had no P.P. violations)
Linkage 1, cost vector = (UNUSED=0 DIS=
2.00 LEN=8)
+------------------Xp-----------------+
+----------->WV---------->+ |
+->Ws--+--H-+--Dmc-+--Spx-+--Pp--+ |
| | | | | | |
LEFT-WALL how many zebras.n are.v there.r ?
(S how many zebras.n
(VP are.v
(PP there.r))
?)
52
How link-grammar works?
Link-grammar has predefined dictionary or words associated with allowed link types.
(word: link types) pairs define what type of links can be attached to which word and
from which side.
Also number of global rules for example that links cannot cross each other.
Check the rules:
github.com/opencog/link-grammar/blob/master/data/en/4.0.dict
53
RelEx
Dependency parser that built on graph rewriting rules
Operates on graph built from link-grammar parse
Adds new semantic links between words
Relex parse for “How many zebras are there?”:
_predadj(zebra, there)
_quantity(zebra, _$qVar)
54
Vertices attributes of relex sentence graph
pos(be, verb)
penn-POS(be, VBP)
pos(there, adj)
tense(there, present)
penn-POS(there, JJ)
HYP(there, T)
QUERY-TYPE(_$qVar,
how_much)
penn-POS(_$qVar, CD)
pos(how, adv)
penn-POS(how, RB)
pos(?, punctuation)
noun_number(zebra, plural)
pos(zebra, noun)
penn-POS(zebra, NNS)
pos(_$qVar, adj)
55
Query example
Is the dog black?
_predadj(A, B)::_predadj(dog, black)
(conj-bc (AndLink

(InheritanceLink (VariableNode "$X") (ConceptNode "BoundingBox"))

(EvaluationLink (GroundedPredicateNode "py:runNeuralNetwork")
(ListLink (VariableNode "$X") (ConceptNode "dog")) )

(EvaluationLink (GroundedPredicateNode "py:runNeuralNetwork")
(ListLink (VariableNode "$X") (ConceptNode "black")) ))

)
56
Image processing
Bounding Boxes & features
Faster-RCNN
57
Bounding boxes => atomspace
ConceptNode("BoundingBox1")
ConceptNode("BoundingBox2")
ConceptNode("BoundingBox3")
Bounding Boxes & features
atomspace
58
Bounding boxes => atomspace
> (InheritanceLink
(ConceptNode("BoundingBox1")
(ConceptNode("BoundingBox"))
59
Use of URE and pattern matcher for queries
•URE allows to use declarative approach for computing answers
•We use fuzzy logic rules to compute truth value of queries
60
61
Integrating opencog with neural networks
Stay tuned!
Passing arbitrary python objects between ExecutionOutputLinks
Allows to express computation graph as pytorch expression
Allows to integrate and update ontologies
62
Resources
wiki.opencog.org/
github.com/opencog/
github.com/singnet/semantic-vision
blog.singularitynet.io
63

More Related Content

What's hot

groovy rules
groovy rulesgroovy rules
groovy rulesPaul King
 
Gpars concepts explained
Gpars concepts explainedGpars concepts explained
Gpars concepts explainedVaclav Pech
 
JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksDoug Hawkins
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Siouxnikomatsakis
 
Rust Intro @ Roma Rust meetup
Rust Intro @ Roma Rust meetup Rust Intro @ Roma Rust meetup
Rust Intro @ Roma Rust meetup Claudio Capobianco
 
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?Henri Tremblay
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
Parsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons LearnedParsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons LearnedDaniel Lemire
 
Bridge TensorFlow to run on Intel nGraph backends (v0.4)
Bridge TensorFlow to run on Intel nGraph backends (v0.4)Bridge TensorFlow to run on Intel nGraph backends (v0.4)
Bridge TensorFlow to run on Intel nGraph backends (v0.4)Mr. Vengineer
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQLPeter Eisentraut
 
Guaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in RustGuaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in Rustnikomatsakis
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Vavr Java User Group Rheinland
Vavr Java User Group RheinlandVavr Java User Group Rheinland
Vavr Java User Group RheinlandDavid Schmitz
 
From Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOSFrom Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOSSusan Potter
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Campjulien.ponge
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011julien.ponge
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 

What's hot (20)

groovy rules
groovy rulesgroovy rules
groovy rules
 
Gpars concepts explained
Gpars concepts explainedGpars concepts explained
Gpars concepts explained
 
JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's Tricks
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Sioux
 
Rust Intro @ Roma Rust meetup
Rust Intro @ Roma Rust meetup Rust Intro @ Roma Rust meetup
Rust Intro @ Roma Rust meetup
 
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
Parsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons LearnedParsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons Learned
 
Bridge TensorFlow to run on Intel nGraph backends (v0.4)
Bridge TensorFlow to run on Intel nGraph backends (v0.4)Bridge TensorFlow to run on Intel nGraph backends (v0.4)
Bridge TensorFlow to run on Intel nGraph backends (v0.4)
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 
Guaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in RustGuaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in Rust
 
bluespec talk
bluespec talkbluespec talk
bluespec talk
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Vavr Java User Group Rheinland
Vavr Java User Group RheinlandVavr Java User Group Rheinland
Vavr Java User Group Rheinland
 
From Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOSFrom Zero to Application Delivery with NixOS
From Zero to Application Delivery with NixOS
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
分散式系統
分散式系統分散式系統
分散式系統
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 

Similar to OpenCog Developer Workshop

Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConqeTimeline, LLC
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regexYongqiang Li
 
Extracting data from text documents using the regex
Extracting data from text documents using the regexExtracting data from text documents using the regex
Extracting data from text documents using the regexSteve Mylroie
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetupsource{d}
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandrarantav
 
Optimizing Tcl Bytecode
Optimizing Tcl BytecodeOptimizing Tcl Bytecode
Optimizing Tcl BytecodeDonal Fellows
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiDatabricks
 
BarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationsBarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationswalkmod
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedDennis de Greef
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 
Real-Time Big Data with Storm, Kafka and GigaSpaces
Real-Time Big Data with Storm, Kafka and GigaSpacesReal-Time Big Data with Storm, Kafka and GigaSpaces
Real-Time Big Data with Storm, Kafka and GigaSpacesOleksii Diagiliev
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the webMichiel Borkent
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Susan Potter
 
Logic programming a ruby perspective
Logic programming a ruby perspectiveLogic programming a ruby perspective
Logic programming a ruby perspectiveNorman Richards
 
Echtzeitapplikationen mit Elixir und GraphQL
Echtzeitapplikationen mit Elixir und GraphQLEchtzeitapplikationen mit Elixir und GraphQL
Echtzeitapplikationen mit Elixir und GraphQLMoritz Flucht
 
Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13specialk29
 

Similar to OpenCog Developer Workshop (20)

Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regex
 
Extracting data from text documents using the regex
Extracting data from text documents using the regexExtracting data from text documents using the regex
Extracting data from text documents using the regex
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetup
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandra
 
Modern C++
Modern C++Modern C++
Modern C++
 
Collections forceawakens
Collections forceawakensCollections forceawakens
Collections forceawakens
 
Optimizing Tcl Bytecode
Optimizing Tcl BytecodeOptimizing Tcl Bytecode
Optimizing Tcl Bytecode
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
 
BarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationsBarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformations
 
Measuring maintainability; software metrics explained
Measuring maintainability; software metrics explainedMeasuring maintainability; software metrics explained
Measuring maintainability; software metrics explained
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
Real-Time Big Data with Storm, Kafka and GigaSpaces
Real-Time Big Data with Storm, Kafka and GigaSpacesReal-Time Big Data with Storm, Kafka and GigaSpaces
Real-Time Big Data with Storm, Kafka and GigaSpaces
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the web
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 
Logic programming a ruby perspective
Logic programming a ruby perspectiveLogic programming a ruby perspective
Logic programming a ruby perspective
 
Echtzeitapplikationen mit Elixir und GraphQL
Echtzeitapplikationen mit Elixir und GraphQLEchtzeitapplikationen mit Elixir und GraphQL
Echtzeitapplikationen mit Elixir und GraphQL
 
Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13Seattle Scalability Meetup 6-26-13
Seattle Scalability Meetup 6-26-13
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

OpenCog Developer Workshop

  • 5. 5 Use cases • Chatbots • Bioinformatics • Unsupervised language learning • Visual Question Answering VQA • …
  • 6. 6 Atomspace - graph database Hypergraph database designed to be primarily used as a storage of explicit, declarative knowledge Hypergraph defines programming language - Atomese Has a number of associated mechanisms: pattern matching, unified rule engine, moses
  • 7. 7 Types of data in atomspace: Atoms Atom LinkNode
  • 8. 8 Types of data in atomspace: Values StringValue LinkValueFloatValue TruthValue
  • 9. 9 Atomspace - API introduction Python: >> from opencog.atomspace import AtomSpace, types >> atomspace = AtomSpace() Scheme: scheme> (use-modules (opencog)) scheme> (define atomspace (cog-new-atomspace))
  • 10. 10 Pattern matcher examples $ docker run -p8888:8888  -it demo-opencog /home/relex/opencog-intro-master/ notebook.sh $ http://localhost:8888/notebooks/and- link-example.ipynb
  • 11. 11 Loading and storing Load scheme file from scheme or python: >> scheme_eval(atomspace, '(load-from-path “atomspace.scm")') Indexed by atom type and name Use PostgreSQL as backend storage
  • 12. 12
  • 13. 13
  • 14. 14 Nodes examples scheme@(guile-user)> (ConceptNode "Test") scheme@(guile-user)> (VariableNode "X") scheme@(guile-user)> (PredicateNode "is-red")
  • 15. 15 Links examples: ListLink >>> lst1 = ListLink(ConceptNode("red"), VariableNode("$X"), ConceptNode("blue")) >>> print(str(lst1)) (ListLink (ConceptNode "red") (VariableNode "$X") (ConceptNode "blue") )
  • 16. 16 TruthValue > from opencog.atomspace import TruthValue > tv = TruthValue(0.5, 0.92) P(Heads) = 0.5, .3 > ConceptNode(“Heads”).tv = tv
  • 17. 17
  • 18. 18
  • 19. 19 BindLink and pattern matcher BindLink
 <variables> - optional
   <pattern to match>
   <rewrite term> Pattern example: ListLink(ConceptNode("red"),       VariableNode("$X"),         ConceptNode("blue"))
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26 Unified Rule Engine Inference engine based on graph rewriting rules. Allows to perform declarative inference. Rules and data defined in the same language - atomese Can do backward and forward chaining
  • 27. 27 Unified Rule Engine Inference in first-order logic Automatic differentiation Graphical models Probabilistic logic inference Fuzzy logic inference ...
  • 28. 28
  • 29. 29
  • 30. 30 Running backward chainer > request = InheritanceLink(ConceptNode("Socrates"),                ConceptNode("mortal")) > tr = AtomSpace() # trace atomspace > rule_base = ConceptNode("PLN") # rules to use > chainer = BackwardChainer(atomspace, rule_base,   request,   trace_as=tr) > chainer.do_chain() > print(chainer.get_results())
  • 31. 31 Defining problem > InheritanceLink(ConceptNode("Socrates"), ConceptNode("man")).tv = TruthValue(0.97, 0.92) > InheritanceLink(ConceptNode("man"), ConceptNode("mortal")).tv = TruthValue(0.98, 0.94) InheritanceLink(ConceptNode("Socrates"), ConceptNode("mortal")).tv = ???
  • 32. 32 Result > (SetLink (InheritanceLink (stv 0.9508 0.828) (ConceptNode(“Socrates”), (ConceptNode("mortal"))
  • 34. 34 Calculate conclusion with ExecutionOutputLink ExecutionOutputLink
 GroundedSchemaNode <formula-name>
 List <conclusion-pattern> <other arguments>
  • 35. 35
  • 36. 36 Deduction rule example premise A -> B B -> C Ergo: A -> C condition = AndLink(BA, CB) BA = InheritanceLink(var_b, var_a) CB = InheritanceLink(var_c, var_b) rewrite = ExecutionOutputLink( GroundedSchemaNode("scm: deduction-formula"), ListLink(CA, CB, BA)) deduction_link = BindLink(condition, rewrite)
  • 37. 37
  • 38. 38
  • 39. 39
  • 40. 40
  • 41. 41
  • 42. 42 BindLink the query was answered with (ExecutionOutputLink (GroundedSchemaNode "scm: deduction-formula") (ListLink (InheritanceLink (stv 0.9508 0.828) (ConceptNode "Socrates") (ConceptNode "mortal") ) (InheritanceLink (ConceptNode "Socrates") (VariableNode "$B") ) (InheritanceLink (VariableNode "$B") (ConceptNode "mortal") ))) (AndLink (InheritanceLink (VariableNode "$B") (ConceptNode "mortal") ) (NotLink (IdenticalLink (ConceptNode "Socrates") (ConceptNode "mortal") ) ) (InheritanceLink (ConceptNode "Socrates") (VariableNode "$B") ))
  • 43. 43 Running VQA demo from the docker image $ docker pull opencog/vqa $ wget https://s3-us-west-2.amazonaws.com/ abelikov/data-small.tar.gz && tar -xvf data- small.tar.gz $ docker run  -v `pwd`/data:/home/relex/projects/ data -p 8889:8888 -it demo-opencog
  • 44. 44
  • 45. 45
  • 46. 46
  • 47. 47 Building VQA with OpenCog Building blocks: Atomspace for storing facts about world Link-Grammar + RelEx for text processing Faster-RCNN for bounding box and feature extraction Our neural network models for classification Unified rule engine and pattern matcher for computing answers
  • 48. 48 VQA pipeline overview How many animals are there? PatternMatcherVQA (python) atomspace Relex + link-grammar (java) Pattern matcher
  • 49. 49 Knowledge base atomspace (InheritanceLink (stv 0.795 0.71) (ConceptNode "van") (ConceptNode "vehicle")) (InheritanceLink (stv 0.576 0.525) (ConceptNode "van") (ConceptNode "auto"))
  • 50. 50 VQA pipeline: text processing sentence => link-grammar => relex => template => query
  • 51. 51 Taking a look at link-grammar linkparser> How many zebras are there? Found 22 linkages (6 had no P.P. violations) Linkage 1, cost vector = (UNUSED=0 DIS= 2.00 LEN=8) +------------------Xp-----------------+ +----------->WV---------->+ | +->Ws--+--H-+--Dmc-+--Spx-+--Pp--+ | | | | | | | | LEFT-WALL how many zebras.n are.v there.r ? (S how many zebras.n (VP are.v (PP there.r)) ?)
  • 52. 52 How link-grammar works? Link-grammar has predefined dictionary or words associated with allowed link types. (word: link types) pairs define what type of links can be attached to which word and from which side. Also number of global rules for example that links cannot cross each other. Check the rules: github.com/opencog/link-grammar/blob/master/data/en/4.0.dict
  • 53. 53 RelEx Dependency parser that built on graph rewriting rules Operates on graph built from link-grammar parse Adds new semantic links between words Relex parse for “How many zebras are there?”: _predadj(zebra, there) _quantity(zebra, _$qVar)
  • 54. 54 Vertices attributes of relex sentence graph pos(be, verb) penn-POS(be, VBP) pos(there, adj) tense(there, present) penn-POS(there, JJ) HYP(there, T) QUERY-TYPE(_$qVar, how_much) penn-POS(_$qVar, CD) pos(how, adv) penn-POS(how, RB) pos(?, punctuation) noun_number(zebra, plural) pos(zebra, noun) penn-POS(zebra, NNS) pos(_$qVar, adj)
  • 55. 55 Query example Is the dog black? _predadj(A, B)::_predadj(dog, black) (conj-bc (AndLink
 (InheritanceLink (VariableNode "$X") (ConceptNode "BoundingBox"))
 (EvaluationLink (GroundedPredicateNode "py:runNeuralNetwork") (ListLink (VariableNode "$X") (ConceptNode "dog")) )
 (EvaluationLink (GroundedPredicateNode "py:runNeuralNetwork") (ListLink (VariableNode "$X") (ConceptNode "black")) ))
 )
  • 56. 56 Image processing Bounding Boxes & features Faster-RCNN
  • 57. 57 Bounding boxes => atomspace ConceptNode("BoundingBox1") ConceptNode("BoundingBox2") ConceptNode("BoundingBox3") Bounding Boxes & features atomspace
  • 58. 58 Bounding boxes => atomspace > (InheritanceLink (ConceptNode("BoundingBox1") (ConceptNode("BoundingBox"))
  • 59. 59 Use of URE and pattern matcher for queries •URE allows to use declarative approach for computing answers •We use fuzzy logic rules to compute truth value of queries
  • 60. 60
  • 61. 61 Integrating opencog with neural networks Stay tuned! Passing arbitrary python objects between ExecutionOutputLinks Allows to express computation graph as pytorch expression Allows to integrate and update ontologies
  • 63. 63