UDP NARS example for end to end communication

46 views
Skip to first unread message

stephen clark

unread,
Aug 28, 2021, 4:52:18 PM8/28/21
to open-nars
Hi,

I see there is an example using UDPNAR to send info to the service but
no example of querying UDPNARS after some time.

https://github.com/opennars/OpenNARS-for-Applications/wiki/UDPNAR


Could someone show an example of an end to end process that sends some
statements to ONA over UDP, lets ONA crunch the data and then query it
for the top 5 concepts.

thanks

Stephen


robe...@googlemail.com

unread,
Aug 29, 2021, 5:33:17 AM8/29/21
to open...@googlegroups.com
There is no such functionality in the codebase.
Tooling could be way better, even in the new implementations.

One can always hack around missing functionality or add it in the code them self.
* Let NARS run with python, open a server in python and broadcast answers to questions to either the client which has posed the question or all clients.

I prefer TCP over UDP for its reliability over faulty internet connections.

--
You received this message because you are subscribed to the Google Groups "open-nars" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-nars+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/open-nars/50b1efe1-476b-db34-494d-40d85dc43ed7%40gmail.com.

robe...@googlemail.com

unread,
Aug 29, 2021, 5:41:51 AM8/29/21
to open...@googlegroups.com
Plus I've implemented a TCP server for my own "NARS"
See "How to run as server"
The server itself is a bit buggy but it should do fine...
Just connect to the TCP server at the port with netcat and terminate lines with linefeed or carry return linefeed (can't remember how the implementation handles it).
Of course attention is not as good as in ONA because I am not using declarative inference much, future versions will be better :) .

Patrick Hammer

unread,
Oct 2, 2021, 7:05:22 PM10/2/21
to open-nars
Hi Stephen!

Sorry I'm a bit late to the party. There is UDP code in UDPNAR_Test.h in system_tests folder.
It shows sending Narsese to another instance for instance when a certain operation is invoked.

The UDP API can also be used to send UDP packets to another network node (not necessarily an UDPNAR instance even) when an operator is called by ONA.

I did not yet extend it to send back answers since I noticed most users use ONA via NAR.py, and in Python it's quite easy to do custom network communication or communication with databases even.
This also made me wonder whether this native network feature is needed at all, or whether it should be removed in a future release. But then I noticed, running the system asynchronously with inputs coming from different sources in the network/internet might still have its uses the synchronous Shell mode doesn't cover well even when wrapped.
Was this feature useful to you so far?

Best regards,
Patrick

stephen clark

unread,
Oct 4, 2021, 11:54:49 AM10/4/21
to open-nars
Patrick

I tried out the code you mentioned but was not able to get a clear set of results back from NARS.  E.g. top 5 concepts

I was able to use Netcat with the -e option to  run an interactive terminal and log the NARS output to a file.

So far I have not completed the parsing of the log file to get build out my inferred knowledge graph.

I was thinking that I might be able to run multiple NARS instances to build out a set of concept categories and then merge them back together.  

I find that NARS tends to forget things or runs out of memory when I send it too much data.

I am trying to use NARS inference engine to create short term memory concepts and a knowledge graph for the long term memory concepts.

Perhaps I may be using NARS in an unusual way but I like the tool your team built and will try to use its unique inference engine for my work.

Thanks for your help
Stephen

--
You received this message because you are subscribed to the Google Groups "open-nars" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-nars+...@googlegroups.com.

Patrick Hammer

unread,
Oct 23, 2021, 1:34:41 PM10/23/21
to open-nars

Hi Stephen!

Sorry for the delay, here some input finally:


"I tried out the code you mentioned but was not able to get a clear set of results back from NARS.  E.g. top 5 concepts"
A command line example:
./NAR shell InspectionOnExit < ./examples/nal/propertymatching.nal | python3 concept_usefulness_filter.py 5 | python3 colorize.py
Without InspectionOnExit ONA won't print the concepts and their content, unless explicitly the *concepts command is input.
To build a knowledge graph, see/use concepts_to_graph.py:
./NAR shell InspectionOnExit < ./examples/nal/propertymatching.nal | python3 concept_usefulness_filter.py 5 | python3 concepts_to_graph.py
besides creating a NetworkX graph it also outputs it as a graphml file.

"I was thinking that I might be able to run multiple NARS instances to build out a set of concept categories and then merge them back together."
Yes that's totally possible! Example getting the best 5 concepts of two runs on different examples (please make sure to pull newest master):
./NAR shell InspectionOnExit < ./examples/nal/propertymatching.nal | python3 concept_usefulness_filter.py 5 > mergedMemory
./NAR shell InspectionOnExit < ./examples/nal/diagnostic.nal | python3 concept_usefulness_filter.py 5 >> mergedMemory
Now, starting an instance with the merged concepts which are 10 in total:
./NAR shell < mergedMemory
or interactively:
cat mergedMemory /dev/stdin | ./NAR shell
or visualizing the merged content and creating a graphml file:
./NAR shell InspectionOnExit < mergedMemory | python3 concept_usefulness_filter.py 10 | python3 concepts_to_graph.py

"I find that NARS tends to forget things or runs out of memory when I send it too much data."
Memory size can be adjusted, but when entering floods of input at some point it will of course reach the limit and will kick out what has been used least often.

"I am trying to use NARS inference engine to create short term memory concepts and a knowledge graph for the long term memory concepts."
"Perhaps I may be using NARS in an unusual way but I like the tool your team built and will try to use its unique inference engine for my work."
The way you use it seems fine to me!
Feel free to play with ConceptNet as well, if you like how this channel works you can of course attach your own KB in a similar fashion, example:
python3 english_to_narsese.py | python3 concept_net_narsese.py | ./NAR shell | python3 colorize.py
A car is made of what?
Answer: <(car * metal) --> make_of>. ...

Best regards,
Patrick


Patrick Hammer

unread,
Jan 18, 2022, 1:32:02 PM1/18/22
to open...@googlegroups.com
Hi Stephen!

I've created a new section (Full UDP input and output) in the UDPNAR page (tested on Ubuntu):

As you likely already know command *concepts lets ONA print all concepts, which can be used as usual to pipe to concept_usefulness_filter.py, to achieve what you mentioned in the first post, filtering the best concepts.
Sorry I didn't realize earlier that your use case was in fact already supported.

Also, following UNIX philosophy, UDPNAR will likely be removed in the future. The second command will then be
nc -ul 127.0.0.1 -p 50000 | ./NAR shell asynchronous 100000 | nc -w 1 -u 127.0.0.1 50001
instead of:
./NAR UDPNAR 127.0.0.1 50000 100000 true | nc -w 1 -u 127.0.0.1 50001

ONA will then not depend on any OS API spec anymore, not even on POSIX.

Best regards,
Patrick

--
You received this message because you are subscribed to the Google Groups "open-nars" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-nars+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages